mirror of
https://github.com/imgurbot12/rmenu.git
synced 2025-02-12 21:25:03 +01:00
feat: hide duplicate desktop files by default
This commit is contained in:
parent
ab1b68e7db
commit
e6b8018cb5
2 changed files with 19 additions and 2 deletions
|
@ -6,9 +6,9 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
clap = { version = "4.5.9", features = ["derive"] }
|
||||||
freedesktop-desktop-entry = "0.5.2"
|
freedesktop-desktop-entry = "0.5.2"
|
||||||
freedesktop-icons = "0.2.6"
|
itertools = "0.13.0"
|
||||||
log = "0.4.21"
|
|
||||||
once_cell = "1.19.0"
|
once_cell = "1.19.0"
|
||||||
rayon = "1.10.0"
|
rayon = "1.10.0"
|
||||||
regex = "1.10.4"
|
regex = "1.10.4"
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
use std::fs::read_to_string;
|
use std::fs::read_to_string;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use clap::Parser;
|
||||||
use freedesktop_desktop_entry::{DesktopEntry, Iter};
|
use freedesktop_desktop_entry::{DesktopEntry, Iter};
|
||||||
|
use itertools::Itertools;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
@ -117,7 +119,15 @@ fn assign_icon(icon: String, map: &icons::IconMap) -> Option<String> {
|
||||||
Some(icon)
|
Some(icon)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Parser)]
|
||||||
|
struct Cli {
|
||||||
|
/// Only Allow Unique Desktop Entries
|
||||||
|
#[clap(short, long)]
|
||||||
|
non_unique: bool,
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
let cli = Cli::parse();
|
||||||
let locale = Some("en");
|
let locale = Some("en");
|
||||||
let sizes = vec![64, 32, 96, 22, 128];
|
let sizes = vec![64, 32, 96, 22, 128];
|
||||||
|
|
||||||
|
@ -130,6 +140,13 @@ fn main() {
|
||||||
let app_paths = data_dirs("applications");
|
let app_paths = data_dirs("applications");
|
||||||
let mut desktops: Vec<Entry> = Iter::new(app_paths)
|
let mut desktops: Vec<Entry> = Iter::new(app_paths)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
.unique_by(|f| match cli.non_unique {
|
||||||
|
true => f.to_str().map(|s| s.to_owned()),
|
||||||
|
false => f
|
||||||
|
.file_name()
|
||||||
|
.and_then(|n| n.to_str())
|
||||||
|
.map(|s| s.to_string()),
|
||||||
|
})
|
||||||
.filter_map(|f| parse_desktop(&f, locale))
|
.filter_map(|f| parse_desktop(&f, locale))
|
||||||
.map(|mut e| {
|
.map(|mut e| {
|
||||||
e.icon = e.icon.and_then(|s| assign_icon(s, &icons));
|
e.icon = e.icon.and_then(|s| assign_icon(s, &icons));
|
||||||
|
|
Loading…
Reference in a new issue