mirror of
https://github.com/imgurbot12/rmenu.git
synced 2025-01-12 23:36:29 +01:00
feat: cleaned up desktop-plugin
This commit is contained in:
parent
07db986da1
commit
48af7cee47
3 changed files with 5 additions and 24 deletions
|
@ -5,5 +5,5 @@ members = [
|
|||
"rmenu-plugin",
|
||||
"plugin-run",
|
||||
"plugin-desktop",
|
||||
"rtest",
|
||||
"plugin-desktop2",
|
||||
]
|
||||
|
|
|
@ -131,7 +131,7 @@ impl<'a> ThemeSpec<'a> {
|
|||
|
||||
/// Sort Theme Directories by Priority, Append Root, and Collect Names Only
|
||||
#[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.push(PathPriority::new("".into(), 0));
|
||||
dirs.into_iter().map(|p| p.path.to_owned()).collect()
|
||||
|
@ -180,7 +180,7 @@ fn parse_index(spec: &ThemeSpec) -> Result<ThemeInfo, ThemeError> {
|
|||
Ok(ThemeInfo {
|
||||
priority: index,
|
||||
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 {
|
||||
name,
|
||||
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 {
|
||||
let mut icon_paths = crate::data_dirs("icons");
|
||||
let icon_paths = crate::data_dirs("icons");
|
||||
let themes = active_themes(cfg, &icon_paths);
|
||||
Self::new(icon_paths, themes, sizes)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ use std::fs::read_to_string;
|
|||
use std::path::PathBuf;
|
||||
|
||||
use freedesktop_desktop_entry::{DesktopEntry, Iter};
|
||||
use freedesktop_icons::lookup;
|
||||
use once_cell::sync::Lazy;
|
||||
use regex::Regex;
|
||||
use rmenu_plugin::{Action, Entry, Method};
|
||||
|
@ -36,24 +35,6 @@ fn data_dirs(dir: &str) -> Vec<PathBuf> {
|
|||
.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...
|
||||
#[inline(always)]
|
||||
fn fix_exec(exec: &str) -> String {
|
||||
|
|
Loading…
Reference in a new issue