forked from mirrors/rmenu
feat: cleaned up desktop-plugin
This commit is contained in:
parent
07db986da1
commit
48af7cee47
@ -5,5 +5,5 @@ members = [
|
|||||||
"rmenu-plugin",
|
"rmenu-plugin",
|
||||||
"plugin-run",
|
"plugin-run",
|
||||||
"plugin-desktop",
|
"plugin-desktop",
|
||||||
"rtest",
|
"plugin-desktop2",
|
||||||
]
|
]
|
||||||
|
@ -131,7 +131,7 @@ impl<'a> ThemeSpec<'a> {
|
|||||||
|
|
||||||
/// Sort Theme Directories by Priority, Append Root, and Collect Names Only
|
/// Sort Theme Directories by Priority, Append Root, and Collect Names Only
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sort_dirs(base: &PathBuf, dirs: &mut Vec<PathPriority>) -> Vec<PathBuf> {
|
fn sort_dirs(dirs: &mut Vec<PathPriority>) -> Vec<PathBuf> {
|
||||||
dirs.sort_by_key(|p| p.priority);
|
dirs.sort_by_key(|p| p.priority);
|
||||||
dirs.push(PathPriority::new("".into(), 0));
|
dirs.push(PathPriority::new("".into(), 0));
|
||||||
dirs.into_iter().map(|p| p.path.to_owned()).collect()
|
dirs.into_iter().map(|p| p.path.to_owned()).collect()
|
||||||
@ -180,7 +180,7 @@ fn parse_index(spec: &ThemeSpec) -> Result<ThemeInfo, ThemeError> {
|
|||||||
Ok(ThemeInfo {
|
Ok(ThemeInfo {
|
||||||
priority: index,
|
priority: index,
|
||||||
name: name.to_owned(),
|
name: name.to_owned(),
|
||||||
paths: sort_dirs(spec.root, &mut directories),
|
paths: sort_dirs(&mut directories),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ fn guess_index(spec: &ThemeSpec) -> Result<ThemeInfo, ThemeError> {
|
|||||||
Ok(ThemeInfo {
|
Ok(ThemeInfo {
|
||||||
name,
|
name,
|
||||||
priority: index,
|
priority: index,
|
||||||
paths: sort_dirs(spec.root, &mut directories),
|
paths: sort_dirs(&mut directories),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ impl IconSpec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn standard(cfg: &PathBuf, sizes: Vec<usize>) -> Self {
|
pub fn standard(cfg: &PathBuf, sizes: Vec<usize>) -> Self {
|
||||||
let mut icon_paths = crate::data_dirs("icons");
|
let icon_paths = crate::data_dirs("icons");
|
||||||
let themes = active_themes(cfg, &icon_paths);
|
let themes = active_themes(cfg, &icon_paths);
|
||||||
Self::new(icon_paths, themes, sizes)
|
Self::new(icon_paths, themes, sizes)
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ use std::fs::read_to_string;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use freedesktop_desktop_entry::{DesktopEntry, Iter};
|
use freedesktop_desktop_entry::{DesktopEntry, Iter};
|
||||||
use freedesktop_icons::lookup;
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use rmenu_plugin::{Action, Entry, Method};
|
use rmenu_plugin::{Action, Entry, Method};
|
||||||
@ -36,24 +35,6 @@ fn data_dirs(dir: &str) -> Vec<PathBuf> {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find Freedesktop Default Theme
|
|
||||||
fn default_theme() -> String {
|
|
||||||
data_dirs("icons")
|
|
||||||
.into_iter()
|
|
||||||
.map(|p| p.join("default/index.theme"))
|
|
||||||
.filter(|p| p.exists())
|
|
||||||
.find_map(|p| {
|
|
||||||
let content = read_to_string(&p).ok()?;
|
|
||||||
let config = DesktopEntry::decode(&p, &content).ok()?;
|
|
||||||
config
|
|
||||||
.groups
|
|
||||||
.get("Icon Theme")
|
|
||||||
.and_then(|g| g.get("Name"))
|
|
||||||
.map(|key| key.0.to_owned())
|
|
||||||
})
|
|
||||||
.unwrap_or_else(|| "Hicolor".to_string())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Modify Exec Statements to Remove %u/%f/etc...
|
/// Modify Exec Statements to Remove %u/%f/etc...
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn fix_exec(exec: &str) -> String {
|
fn fix_exec(exec: &str) -> String {
|
||||||
|
Loading…
Reference in New Issue
Block a user