filter drun menu better and make some commands actually run
This commit is contained in:
parent
ddf95551fd
commit
437763f51f
5 changed files with 82 additions and 15 deletions
54
Cargo.lock
generated
54
Cargo.lock
generated
|
|
@ -391,6 +391,12 @@ dependencies = [
|
||||||
"regex",
|
"regex",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "env_home"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c7f84e12ccf0a7ddc17a6c41c93326024c42920d7ee630d04950e6926645c0fe"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "env_logger"
|
name = "env_logger"
|
||||||
version = "0.11.8"
|
version = "0.11.8"
|
||||||
|
|
@ -410,6 +416,16 @@ version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "errno"
|
||||||
|
version = "0.3.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"windows-sys 0.59.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "field-offset"
|
name = "field-offset"
|
||||||
version = "0.3.6"
|
version = "0.3.6"
|
||||||
|
|
@ -970,6 +986,12 @@ version = "0.5.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
|
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "linux-raw-sys"
|
||||||
|
version = "0.9.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.27"
|
version = "0.4.27"
|
||||||
|
|
@ -1259,6 +1281,19 @@ dependencies = [
|
||||||
"semver",
|
"semver",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustix"
|
||||||
|
version = "1.0.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.9.0",
|
||||||
|
"errno",
|
||||||
|
"libc",
|
||||||
|
"linux-raw-sys",
|
||||||
|
"windows-sys 0.59.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.20"
|
version = "1.0.20"
|
||||||
|
|
@ -1534,6 +1569,18 @@ version = "0.11.0+wasi-snapshot-preview1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "which"
|
||||||
|
version = "7.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "24d643ce3fd3e5b54854602a080f34fb10ab75e0b813ee32d00ca2b44fa74762"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
"env_home",
|
||||||
|
"rustix",
|
||||||
|
"winsafe",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
|
|
@ -1656,6 +1703,12 @@ dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winsafe"
|
||||||
|
version = "0.0.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "worf"
|
name = "worf"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
@ -1679,6 +1732,7 @@ dependencies = [
|
||||||
"strsim 0.11.1",
|
"strsim 0.11.1",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"toml",
|
"toml",
|
||||||
|
"which",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
||||||
|
|
@ -41,3 +41,4 @@ libc = "0.2.171"
|
||||||
freedesktop-file-parser = "0.1.3"
|
freedesktop-file-parser = "0.1.3"
|
||||||
strsim = "0.11.1"
|
strsim = "0.11.1"
|
||||||
dirs = "6.0.0"
|
dirs = "6.0.0"
|
||||||
|
which = "7.0.3"
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,12 @@ layerrule = blur, worf
|
||||||
because worf is build on GTK4 instead of GTK3 there will be differences in the look and feel.
|
because worf is build on GTK4 instead of GTK3 there will be differences in the look and feel.
|
||||||
* Configuration files are not 100% compatible, Worf is using toml files instead, for most part this only means strings have to be quoted
|
* Configuration files are not 100% compatible, Worf is using toml files instead, for most part this only means strings have to be quoted
|
||||||
* Color files are not supported
|
* Color files are not supported
|
||||||
* `mode` dropped, use show
|
|
||||||
* `D` argument dropped. Arguments are the same as config in worf, no need to have have this flag.
|
|
||||||
|
|
||||||
## Dropped configuration options
|
## Dropped arguments
|
||||||
|
* `mode`, use show
|
||||||
|
* `D`, arguments are the same as config in worf, no need to have have this flag.
|
||||||
|
|
||||||
|
### Dropped configuration options
|
||||||
* stylesheet -> use style instead
|
* stylesheet -> use style instead
|
||||||
* color / colors -> GTK4 does not support color files
|
* color / colors -> GTK4 does not support color files
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,17 +42,30 @@ pub fn d_run(config: &Config) -> anyhow::Result<()> {
|
||||||
f.entry.hidden.is_none_or(|hidden| !hidden)
|
f.entry.hidden.is_none_or(|hidden| !hidden)
|
||||||
&& f.entry.no_display.is_none_or(|no_display| !no_display)
|
&& f.entry.no_display.is_none_or(|no_display| !no_display)
|
||||||
}) {
|
}) {
|
||||||
let (action, working_dir) = match &file.entry.entry_type {
|
|
||||||
EntryType::Application(app) => (app.exec.clone(), app.path.clone()),
|
|
||||||
_ => (None, None),
|
|
||||||
};
|
|
||||||
|
|
||||||
let Some(name) = lookup_name_with_locale(
|
let Some(name) = lookup_name_with_locale(
|
||||||
&locale_variants,
|
&locale_variants,
|
||||||
&file.entry.name.variants,
|
&file.entry.name.variants,
|
||||||
&file.entry.name.default,
|
&file.entry.name.default,
|
||||||
) else {
|
) else {
|
||||||
log::debug!("Skipping desktop entry without name {file:?}");
|
log::warn!("Skipping desktop entry without name {file:?}");
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
let (action, working_dir) = match &file.entry.entry_type {
|
||||||
|
EntryType::Application(app) => (app.exec.clone(), app.path.clone()),
|
||||||
|
_ => (None, None),
|
||||||
|
};
|
||||||
|
|
||||||
|
let cmd_exists = action.as_ref().map(|a| {
|
||||||
|
a.split(' ')
|
||||||
|
.next()
|
||||||
|
.map(|cmd| cmd.replace("\"", ""))
|
||||||
|
.map(|cmd| {
|
||||||
|
PathBuf::from(&cmd).exists() || which::which(&cmd).is_ok()
|
||||||
|
})}).flatten().unwrap_or(false);
|
||||||
|
|
||||||
|
if !cmd_exists {
|
||||||
|
log::warn!("Skipping desktop entry for {name:?} because action {action:?} does not exist");
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -174,11 +187,8 @@ fn create_file_if_not_exists(path: &PathBuf) -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spawn_fork(cmd: &str, working_dir: Option<&String>) -> anyhow::Result<()> {
|
fn spawn_fork(cmd: &str, working_dir: Option<&String>) -> anyhow::Result<()> {
|
||||||
// todo probably remove arguments?
|
// todo fix actions ??
|
||||||
// todo support working dir
|
|
||||||
// todo fix actions
|
|
||||||
// todo graphical disk map icon not working
|
// todo graphical disk map icon not working
|
||||||
// Unix-like systems (Linux, macOS)
|
|
||||||
|
|
||||||
let parts = cmd.split(' ').collect::<Vec<_>>();
|
let parts = cmd.split(' ').collect::<Vec<_>>();
|
||||||
if parts.is_empty() {
|
if parts.is_empty() {
|
||||||
|
|
@ -189,7 +199,7 @@ fn spawn_fork(cmd: &str, working_dir: Option<&String>) -> anyhow::Result<()> {
|
||||||
env::set_current_dir(dir)?;
|
env::set_current_dir(dir)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let exec = parts[0];
|
let exec = parts[0].replace("\"", "");
|
||||||
let args: Vec<_> = parts
|
let args: Vec<_> = parts
|
||||||
.iter()
|
.iter()
|
||||||
.skip(1)
|
.skip(1)
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
|
|
||||||
env_logger::Builder::new()
|
env_logger::Builder::new()
|
||||||
// todo change to error as default
|
// todo change to error as default
|
||||||
.parse_filters(&env::var("RUST_LOG").unwrap_or_else(|_| "debug".to_owned()))
|
.parse_filters(&env::var("RUST_LOG").unwrap_or_else(|_| "error".to_owned()))
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
let args = config::parse_args();
|
let args = config::parse_args();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue