Skip to content

Launcher to enfoce XDG Base Directory compliance for any application.

License

Notifications You must be signed in to change notification settings

hildigerr/xdg-launcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xdg-launcher

Launcher to enfoce XDG Base Directory compliance for any application

Overview

This script is designed to enforce compliance with the XDG Base Directory Specification for applications that do not natively respect the user's XDG settings. By redefining the HOME environment variable and temporarily linking necessary files, this script forces applications store their configuration, cache, and data files in the appropriate XDG-defined locations.

Usage

xdg-launch [-cd <directory>] [--fuzz] [--quiet] <application> [-- <options>]

Arguments

  • -d, --dir, --cd <directory>: Specify a working directory for the application. The script will change to this directory before launching the application.
  • -f, --fuzz: Fuzz the /etc/passwd file for applications that ignore environment variables.
  • --help, -h: Display usage information.
  • --quiet, -q: Quiet mode to supress launcher messages. The launched application's output is not affected.
  • <application>: The application to be launched.
  • [<options>]: Additional options or arguments passed to the application.

How It Works

  1. Environment Setup:

    • The script checks for user's XDG_CONFIG_HOME, XDG_CACHE_HOME, XDG_DATA_HOME, and XDG_STATE_HOME.
    • If they are not already defined, the default values are used.
    • Missing directories are created, if needed, just in case.
  2. Resource Useage Registratoin:

    • The launcher aquires a mutex lock on the file $XDG_STATE_HOME/xdg/launcher.lock.
    • The quantity of applications using links within the specified XDG_DATA_HOME is incremented.
    • This data is saved within the $XDG_STATE_HOME/xdg/launcher.data file.
  3. Temporary Links: Temporary links to the following items are created within XDG_DATA_HOME.

    • .cache
    • .config
    • .Xauthority
  4. /etc/passwd Fuzzing (if enabled):

    • A copy of the /etc/passwd file is created as /tmp/$USER/passwd.pid
    • Within the file, the root user's home directory is set to the real user's XDG_DATA_HOME.
  5. Application Launch:

    • The working directory is changed to the specified target directory.
    • The script temporarily redefines the HOME environment variable to point to XDG_DATA_HOME.
    • If enabled, a new private namespace is created which overrides /etc/passwd with the fuzzed version.
    • The specified application is launched with its arguments.
  6. Cleanup After the Application Exits:

    • The number of registerd applications is decremented within the $XDG_STATE_HOME/xdg/launcher.data file.
    • Temporary links are removed unless registered as still in use by another application.
    • Fuzzed passwd files are not removed from the /tmp/$USER/ directory.

Notes

If you have an $XAUTHORITY setting, the .Xauthority link will not be made. It is hoped that the setting works without it. I have not yet been successful in enabling this setting. So if you do have it set, please let me know if this works for you or not.

About

Launcher to enfoce XDG Base Directory compliance for any application.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors