3 releases
0.1.3 | Apr 23, 2022 |
---|---|
0.1.2 | Apr 10, 2022 |
0.1.1 | Apr 9, 2022 |
#300 in Multimedia
41KB
989 lines
xdp-hook-rs
trigger user-configured actions when other apps use xdg-desktop-portal ( https://github.com/flatpak/xdg-desktop-portal )
what?
-
xdg-desktop-portals are a mechanism built on top of dbus and pipewire, used by Linux apps when direct access to sensitive system capabilities is unavailable (or when explicit user consent is desirable)
-
we can use
dbus-monitor
to observe the negotiation and usage of such portals, but it doesn't make it convenient to create a bird's-eye view of active sessions, and might not be the easiest way to trigger portal-related automation, etc -
xdp-hook
's purpose is not to offer privacy indicators like those on Android, but rather to make it easier for others to offer such features, by reacting to portal usage and performing user-configured tasks e.g. executing scripts -
this project depends upon Linux and offers functionality for Linux systems (no support for other environments)
installation
from https://crates.io/ via cargo
-
ensure you have a working Rust toolchain: https://rustup.rs/
-
run
cargo install xdp-hook
configuration
- create ~/.config/xdp-hook/config.toml (see example configuration)
hook environment
when xdp-hook
runs a hook that you have configured,
it attempts to set certain environment variables to expose more information:
XDP_HOOK_APP_ID
: the name of the (flatpak app-like) process (if any) that initiated the portal sessionXDP_HOOK_PROCESS_COMMAND
: the name of the process that initiated the portal sessionXDP_HOOK_PROCESS_ID
: the process ID of the process that initiated the portal session
note that these are "best-effort" and might be empty strings when information is unavailable
features/roadmap
- connect to user's dbus session
- identify and log out general messages relating to portal requests
- track open/close for prolonged portal sessions (e.g. Location, ScreenCast, RemoteDesktop)
- track open/close for prolonged portal sessions (e.g. Inhibit)
- read configuration file ~/.config/xdp-hook/config.toml
- perform user-configured tasks upon portal request/session event e.g. executing scripts
- user-scope systemd unit file for convenient startup
- properly differentiate between concurrent clients for portals (e.g. both Chrome and Firefox using jitsi): https://gitlab.com/jokeyrhyme/xdp-hook-rs/-/issues/3
- identify app/process that is initiating the portal request: https://gitlab.com/jokeyrhyme/xdp-hook-rs/-/issues/3
- identify the portal implementation that handles the portal request (impossible?)
see also
Dependencies
~15–31MB
~438K SLoC