LinuxCommandLibrary

dex

Convert Dalvik Executable (dex) to Java class

TLDR

Execute all programs in the autostart folders

$ dex [[-a|--autostart]]
copy

Execute all programs in the specified folders
$ dex [[-a|--autostart]] [[-s|--search-paths]] [path/to/directory1]:[path/to/directory2]:[path/to/directory3]:
copy

Preview the programs would be executed in a GNOME specific autostart
$ dex [[-a|--autostart]] [[-e|--environment]] [GNOME]
copy

Preview the programs would be executed in a regular autostart
$ dex [[-a|--autostart]] [[-d|--dry-run]]
copy

Preview the value of the DesktopEntry property Name
$ dex [[-p|--property]] [Name] [path/to/file.desktop]
copy

Create a DesktopEntry for a program in the current directory
$ dex [[-c|--create]] [path/to/file.desktop]
copy

Execute a single program (with Terminal=true in the .desktop file) in the given terminal
$ dex --term [terminal] [path/to/file.desktop]
copy

SYNOPSIS

dex [OPTION...] [FILE...]

PARAMETERS

-a, --all
    Launch all matching files found

-e, --environment=NAME=VALUE
    Set environment variable before launch

-i, --in-path
    Search for files in $PATH

-l, --list
    List files that would be launched, without executing

--monitor-stdout=FD
    Monitor stdout of processes on file descriptor FD

--monitor-stderr=FD
    Monitor stderr of processes on file descriptor FD

-q, --quiet
    Suppress non-error output

-r, --root
    Interpret files relative to current directory

--version
    Print version and exit

-h, --help
    Show help and exit

DESCRIPTION

Dex is a lightweight command-line tool designed to run Freedesktop.org .desktop files, enabling seamless launch of desktop applications, scripts, or URIs directly from the terminal. It supports multiple files or URIs at once, making it ideal for automation, scripting, or environments without a full desktop session.

Unlike xdg-open, which handles only single URIs via the default handler, dex specifically parses and executes .desktop entries, respecting their Exec lines, icons, categories, and environment variables. This ensures applications start with correct working directories, arguments, and startup notifications.

Common use cases include batch-launching apps in window managers like i3 or Openbox, integrating into hotkeys, or testing .desktop files during development. It outputs launch status and handles errors gracefully, such as missing files or invalid entries.

CAVEATS

Requires a running X11/Wayland session for GUI apps; may fail silently if no display server. Not all .desktop features (e.g., advanced DBus activation) are fully supported.

EXAMPLES

dex ~/.local/share/applications/firefox.desktop
dex -a ~/Desktop/*.desktop
dex --environment=DISPLAY=:0 file:///path/to/app.desktop

EXIT CODES

0: Success
1: General error
2: Invalid arguments
3: No files launched

HISTORY

Developed by Alastair Sarandi in 2013 as a standalone alternative to heavier desktop launchers. Maintained on GitHub; latest stable release v0.5.4 (2023). Gained popularity in minimal WM setups like i3 and Awesome.

SEE ALSO

xdg-open(1), gio(1), gvfs-open(1), gtk-launch(1)

Copied to clipboard