Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Support for Environment Variable Expansion in .desktop Exec Keys
- Please consider allowing simple environment variable expansion (e.g. $HOME, $XDG_DATA_DIRS) in
- the Exec key of .desktop files, as defined in the XDG Desktop Entry Specification.
- Currently, .desktop entries require fully hardcoded absolute paths in the Exec key.
- This imposes several limitations:
- * User portability: Applications installed in per-user locations (e.g., within $HOME/.local/bin) must hardcode the username or path in each .desktop file,
- making them fragile when moved between systems or user accounts.
- * Dynamic environments: Many modern scripts and tools are aware of or depend on XDG_* environment variables, but .desktop files cannot make use of them.
- * Autostart scripts: Users creating .desktop entries in ~/.config/autostart/ for user login tasks must avoid $HOME and write out full paths, which is inelegant and error-prone.
- * Tooling complexity: Tools that generate .desktop files must resolve these values at generation time, leading to duplication of logic that could otherwise be standardized.
- * Script/package integration: Developers often write scripts or installer routines that dynamically generate .desktop files.
- These scripts could be greatly simplified by supporting environment variable expansion,
- removing the need for runtime resolution or complex path detection logic.
- Allow a restricted and clearly defined set of environment variables to be expanded at runtime only in the Exec key, such as:
- $HOME $USER
- $XDG_CONFIG_DIRS $XDG_SEAT $XDG_SESSION_PATH
- $XDG_CURRENT_DESKTOP $XDG_SEAT_PATH $XDG_SESSION_TYPE
- $XDG_DATA_DIRS $XDG_SESSION_CLASS $XDG_VTNR
- $XDG_GREETER_DATA_DIR $XDG_SESSION_DESKTOP
- $XDG_RUNTIME_DIR $XDG_SESSION_ID
- This could be optionally restricted to known safe variables to prevent arbitrary command execution, and/or specified in a new metadata key such as:
- X-Exec-Allow-Env=true
- Alternatively, expansion could be limited to environment variables already defined in the session, without permitting subshells or command substitution.
- This change would improve the flexibility and portability of .desktop files while remaining consistent with the XDG design goals.
- It would empower users and developers to write cleaner,
- more adaptable launch entries and reduce friction when scripting automation of .desktop files.
- If this functionality is indeed present, pardon me, perhaps I need to update or something.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement