feat(library): Add constants for plugin paths
This commit is contained in:
parent
88acf0a74e
commit
ebb3e83b73
4 changed files with 56 additions and 8 deletions
25
Cargo.lock
generated
25
Cargo.lock
generated
|
|
@ -22,9 +22,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.42"
|
||||
version = "1.0.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "595d3cfa7a60d4555cb5067b99f07142a08ea778de5cf993f7b75c7d8fabc486"
|
||||
checksum = "28ae2b3dec75a406790005a200b1bd89785afc02517a00ca99ecfe093ee9e6cf"
|
||||
|
||||
[[package]]
|
||||
name = "async-channel"
|
||||
|
|
@ -245,6 +245,26 @@ dependencies = [
|
|||
"cache-padded",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "const_format"
|
||||
version = "0.2.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49aad96768495418a04c9349327f32f2cd7e9bf8ac6b142534466048721c8ff5"
|
||||
dependencies = [
|
||||
"const_format_proc_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "const_format_proc_macros"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29c36c619c422113552db4eb28cddba8faa757e33f758cc3415bd2885977b591"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.13.0"
|
||||
|
|
@ -762,6 +782,7 @@ name = "pop-launcher"
|
|||
version = "1.0.0"
|
||||
dependencies = [
|
||||
"blocking",
|
||||
"const_format",
|
||||
"futures-lite",
|
||||
"futures_codec",
|
||||
"serde",
|
||||
|
|
|
|||
|
|
@ -11,9 +11,10 @@ resolver = "2"
|
|||
members = ["bin", "plugins", "service"]
|
||||
|
||||
[dependencies]
|
||||
blocking = "1"
|
||||
const_format = "0.2"
|
||||
futures_codec = "0.4"
|
||||
futures-lite = "1"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
serde_with = "1"
|
||||
futures-lite = "1"
|
||||
futures_codec = "0.4"
|
||||
blocking = "1"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use blocking::Unblock;
|
||||
use futures_codec::{FramedRead, LinesCodec};
|
||||
use futures_lite::{AsyncRead, Stream, StreamExt};
|
||||
use serde::Deserialize;
|
||||
use blocking::Unblock;
|
||||
use std::io;
|
||||
|
||||
/// stdin with AsyncRead support
|
||||
|
|
|
|||
30
src/lib.rs
30
src/lib.rs
|
|
@ -2,8 +2,35 @@ mod codec;
|
|||
|
||||
pub use self::codec::*;
|
||||
|
||||
use const_format::concatcp;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{borrow::Cow, path::PathBuf};
|
||||
use std::{borrow::Cow, path::{Path, PathBuf}};
|
||||
|
||||
pub const LOCAL: &str = "~/.local/share/pop-launcher";
|
||||
pub const LOCAL_PLUGINS: &str = concatcp!(LOCAL, "/plugins");
|
||||
|
||||
pub const SYSTEM: &str = "/etc/pop-launcher";
|
||||
pub const SYSTEM_PLUGINS: &str = concatcp!(SYSTEM, "/plugins");
|
||||
|
||||
pub const DISTRIBUTION: &str = "/usr/lib/pop-launcher";
|
||||
pub const DISTRIBUTION_PLUGINS: &str = concatcp!(DISTRIBUTION, "/plugins");
|
||||
|
||||
pub const PLUGIN_PATHS: &[&str] = &[LOCAL_PLUGINS, SYSTEM_PLUGINS, DISTRIBUTION_PLUGINS];
|
||||
|
||||
pub fn plugin_paths() -> impl Iterator<Item = Cow<'static, Path>> {
|
||||
PLUGIN_PATHS.iter()
|
||||
.map(|path| {
|
||||
#[allow(deprecated)]
|
||||
if let Some(path) = path.strip_prefix("~/") {
|
||||
let path = std::env::home_dir()
|
||||
.expect("user does not have home dir")
|
||||
.join(path);
|
||||
Cow::Owned(path)
|
||||
} else {
|
||||
Cow::Borrowed(Path::new(path))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// u32 value defining the generation of an indice.
|
||||
pub type Generation = u32;
|
||||
|
|
@ -57,7 +84,6 @@ pub struct PluginSearchResult {
|
|||
pub window: Option<(Generation, Indice)>,
|
||||
}
|
||||
|
||||
|
||||
// Sent to the input pipe of the launcher service, and disseminated to its plugins.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub enum Request {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue