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
|
|
@ -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