Go to file
Natty 4dec080054
Version bump
2024-02-03 20:34:03 +01:00
src Accept file URIs via stdin instead 2024-02-03 20:33:28 +01:00
.gitignore Initial commit 2024-02-03 17:03:43 +01:00
Cargo.lock Initial commit 2024-02-03 17:03:43 +01:00
Cargo.toml Version bump 2024-02-03 20:34:03 +01:00
LICENSE.GPLv3 Added licensing 2024-02-03 17:26:41 +01:00
LICENSE.MIT Added licensing 2024-02-03 17:26:41 +01:00
README.md Accept file URIs via stdin instead 2024-02-03 20:33:28 +01:00
org.freedesktop.FileManager1.service Added licensing 2024-02-03 17:26:41 +01:00

README.md

dfmd

A small utility daemon to handle "open containing folder" activities in various software.

🦊

Quick installation

AUR package: dfmd-git

If some other handler takes precedence over this one, try copying the D-Bus service file into your user directory. Also make sure no other service is running while executing dfmd.

Bash et al.:

mkdir -p "${XDG_DATA_HOME:-"$HOME/.local/share"}/dbus-1/services"
cp /usr/share/dbus-1/services/sh.natty.FileManager1.service "${XDG_DATA_HOME:-"$HOME/.local/share"}/dbus-1/services/org.freedesktop.FileManager1.service"

Fish:

# Fallback universal variable in case XDG_DATA_HOME is not set
set -U XDG_DATA_HOME ~/.local/share
mkdir -p "$XDG_DATA_HOME/dbus-1/services"
cp /usr/share/dbus-1/services/sh.natty.FileManager1.service "$XDG_DATA_HOME/dbus-1/services/org.freedesktop.FileManager1.service"

Dependencies

  • D-Bus
  • xdg-open as the default handler

Building

cargo build --release

Configuration

Use the DFMD_*_PROGRAM environment variables. Filenames are provided via stdin, one per line.

Default handler programs

DFMD_FOLDER_PROGRAM="xargs -r -n1 xdg-open"
DFMD_ITEMS_PROGRAM="xargs -r -n1 dirname | xargs -n1 xdg-open"
DFMD_PROPERTIES_PROGRAM="xargs -r -n1 xdg-open"

Autostart

Create a D-Bus service in $XDG_DATA_HOME/dbus-1/services/org.freedesktop.FileManager1.service.

(The default directory for XDG_DATA_HOME is $HOME/.local/share/)

[D-BUS Service]
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="xargs -r -n1 dirname | xargs -n1 notify-send 'File opened'" /usr/bin/dfmd