diff --git a/plugin-desktop/Cargo.toml b/plugin-desktop/Cargo.toml index 02dc2fd..82fd063 100644 --- a/plugin-desktop/Cargo.toml +++ b/plugin-desktop/Cargo.toml @@ -6,14 +6,15 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -freedesktop-desktop-entry = "0.5.0" -freedesktop-icons = "0.2.3" -log = "0.4.19" -once_cell = "1.18.0" -regex = "1.9.1" +freedesktop-desktop-entry = "0.5.2" +freedesktop-icons = "0.2.6" +log = "0.4.21" +once_cell = "1.19.0" +rayon = "1.10.0" +regex = "1.10.4" rmenu-plugin = { version = "0.0.2", path = "../rmenu-plugin" } -rust-ini = "0.19.0" -serde_json = "1.0.104" +rust-ini = "0.21.0" +serde_json = "1.0.117" shellexpand = "3.1.0" -thiserror = "1.0.44" -walkdir = "2.3.3" +thiserror = "1.0.61" +walkdir = "2.5.0" diff --git a/plugin-desktop/src/main.rs b/plugin-desktop/src/main.rs index 420abb8..aaf44db 100644 --- a/plugin-desktop/src/main.rs +++ b/plugin-desktop/src/main.rs @@ -3,6 +3,7 @@ use std::path::PathBuf; use freedesktop_desktop_entry::{DesktopEntry, Iter}; use once_cell::sync::Lazy; +use rayon::prelude::*; use regex::Regex; use rmenu_plugin::{Action, Entry, Method}; @@ -59,7 +60,10 @@ fn parse_desktop(path: &PathBuf, locale: Option<&str>) -> Option { // if an entry only is shown on a specific desktop, check whether desktop is set and matches, // otherwise return None let de = std::env::var(XDG_CURRENT_DESKTOP_ENV); - if entry.only_show_in().is_some_and(|e| !(de.is_ok() && de.unwrap() == e.to_string())){ + if entry + .only_show_in() + .is_some_and(|e| !(de.is_ok() && de.unwrap() == e.to_string())) + { return None; } @@ -133,10 +137,10 @@ fn main() { }) .collect(); - desktops.sort_by_cached_key(|e| e.name.to_owned()); - desktops + desktops.par_sort_by_cached_key(|e| e.name.to_owned()); + let _: Vec<()> = desktops .into_iter() .filter_map(|e| serde_json::to_string(&e).ok()) .map(|s| println!("{}", s)) - .last(); + .collect(); } diff --git a/plugin-run/Cargo.toml b/plugin-run/Cargo.toml index 2bc2549..d6f76ba 100644 --- a/plugin-run/Cargo.toml +++ b/plugin-run/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +rayon = "1.10.0" rmenu-plugin = { version = "0.0.2", path = "../rmenu-plugin" } -serde_json = "1.0.103" -walkdir = "2.3.3" +serde_json = "1.0.117" +walkdir = "2.5.0" diff --git a/plugin-run/src/main.rs b/plugin-run/src/main.rs index def09ca..f954f59 100644 --- a/plugin-run/src/main.rs +++ b/plugin-run/src/main.rs @@ -1,6 +1,7 @@ use std::env; use std::os::unix::fs::PermissionsExt; +use rayon::prelude::*; use rmenu_plugin::Entry; use walkdir::{DirEntry, WalkDir}; @@ -49,16 +50,16 @@ fn find_binaries(path: String) -> Vec { fn main() { // collect entries for sorting let mut entries: Vec = bin_paths() - .into_iter() + .into_par_iter() .map(find_binaries) .flatten() .collect(); // sort entries and render to json - entries.sort_by_cached_key(|e| e.name.clone()); - entries - .into_iter() + entries.par_sort_by_cached_key(|e| e.name.clone()); + let _: Vec<()> = entries + .into_par_iter() .map(|e| serde_json::to_string(&e)) .filter_map(|r| r.ok()) .map(|s| println!("{}", s)) - .last(); + .collect(); }