diff --git a/README.md b/README.md index 7b20a68..48db795 100644 --- a/README.md +++ b/README.md @@ -48,9 +48,9 @@ list of input files. ### Default handler programs ```sh -DFMD_FOLDER_PROGRAM='echo %ARGS% | xargs -n1 xdg-open' -DFMD_ITEMS_PROGRAM='echo %ARGS% | xargs -d " " -I {} sh -c '"'"'p="{}"; echo "${p%/*}"'"'"' | xargs -n1 xdg-open' -DFMD_PROPERTIES_PROGRAM='echo %ARGS% | xargs -n1 xdg-open' +DFMD_FOLDER_PROGRAM="echo %ARGS% | xargs -n1 xdg-open" +DFMD_ITEMS_PROGRAM="echo %ARGS% | xargs -d ' ' -r -n1 dirname | xargs -n1 xdg-open" +DFMD_PROPERTIES_PROGRAM="echo %ARGS% | xargs -n1 xdg-open" ``` ## Autostart @@ -65,3 +65,16 @@ Create a DBus service in Name=org.freedesktop.FileManager1 Exec=path/to/dfmd ``` + +## Overriding defaults in D-Bus service files + +Since D-Bus service files do not understand environment variables, the actions +can be overridden using `env`: + +(Theoretical example where showing a file sends a desktop notification) + +``` +[D-BUS Service] +Name=org.freedesktop.FileManager1 +Exec=env DFMD_ITEMS_PROGRAM="echo %ARGS% | xargs -d ' ' -r -n1 dirname | xargs -n1 notify-send 'File opened'" /usr/bin/dfmd +``` diff --git a/src/main.rs b/src/main.rs index 74c0bee..54fa4f5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -66,9 +66,9 @@ async fn main() -> eyre::Result<()> { .ok() .unwrap_or_else(|| r#"echo %ARGS% | xargs -n1 xdg-open"#.to_string()); - let show_items_program = env::var("DFMD_ITEMS_PROGRAM").ok().unwrap_or_else(|| - r#"echo %ARGS% | xargs -d " " -I {} sh -c 'p="{}"; echo "${p%/*}"' | xargs -n1 xdg-open"#.to_string(), - ); + let show_items_program = env::var("DFMD_ITEMS_PROGRAM").ok().unwrap_or_else(|| { + r#"echo %ARGS% | xargs -d ' ' -r -n1 dirname | xargs -n1 xdg-open"#.to_string() + }); let show_properties_program = env::var("DFMD_PROPERTIES_PROGRAM") .ok()