Better pipes

This commit is contained in:
Natty 2024-02-03 20:17:23 +01:00
parent 3c871e994d
commit 90f2a2db1d
Signed by: natty
GPG Key ID: BF6CB659ADEE60EC
2 changed files with 19 additions and 6 deletions

View File

@ -48,9 +48,9 @@ list of input files.
### Default handler programs ### Default handler programs
```sh ```sh
DFMD_FOLDER_PROGRAM='echo %ARGS% | xargs -n1 xdg-open' 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_ITEMS_PROGRAM="echo %ARGS% | xargs -d ' ' -r -n1 dirname | xargs -n1 xdg-open"
DFMD_PROPERTIES_PROGRAM='echo %ARGS% | xargs -n1 xdg-open' DFMD_PROPERTIES_PROGRAM="echo %ARGS% | xargs -n1 xdg-open"
``` ```
## Autostart ## Autostart
@ -65,3 +65,16 @@ Create a DBus service in
Name=org.freedesktop.FileManager1 Name=org.freedesktop.FileManager1
Exec=path/to/dfmd 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
```

View File

@ -66,9 +66,9 @@ async fn main() -> eyre::Result<()> {
.ok() .ok()
.unwrap_or_else(|| r#"echo %ARGS% | xargs -n1 xdg-open"#.to_string()); .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(|| 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(), r#"echo %ARGS% | xargs -d ' ' -r -n1 dirname | xargs -n1 xdg-open"#.to_string()
); });
let show_properties_program = env::var("DFMD_PROPERTIES_PROGRAM") let show_properties_program = env::var("DFMD_PROPERTIES_PROGRAM")
.ok() .ok()