Freedesktop
- Utilities
- xdg-settings — get various settings from the desktop environment
- xdg-mime – command line tool for querying information about file type handling and adding descriptions for new file types
- desktop-file-validate – Validate desktop entry files
- xdg-desktop-menu – command line tool for (un)installing desktop menu items
- Unsorted
Utilities
xdg-settings — get various settings from the desktop environment
xdg-settings get default-web-browser
https://portland.freedesktop.org/doc/xdg-settings.html
xdg-mime – command line tool for querying information about file type handling and adding descriptions for new file types
xdg-mime query default inode/directory
desktop-file-validate – Validate desktop entry files
The desktop-file-validate program is a tool to validate desktop entry files according to the Desktop Entry specification 1.5.
xdg-desktop-menu – command line tool for (un)installing desktop menu items
The xdg-desktop-menu program can be used to install new menu entries to the desktop’s application menu.
xdg-desktop-menu forceupdate
Unsorted
Desktop files
Directories
| global | /usr/share/applications |
| user | $HOME/.local/share/applications |
| flatpak global | /var/lib/flatpak/exports/share/applications |
| flatpak user | $HOME/.local/share/flatpak/exports/share/applications |
How to add an action
- in the main [Desktop Entry], add Actions=MyAction
- add a [Desktop Action MyAction] section
- put your stuff there
Example (with PokerTH that is always too small):
[Desktop Entry]
Name=PokerTH
GenericName=Poker Card Game
Comment=Texas hold'em game
Exec=pokerth
Icon=pokerth
Terminal=false
Type=Application
X-DCOP-ServiceType=Multi
X-KDE-StartupNotify=true
Categories=Qt;Game;CardGame;
Actions=Bigger
[Desktop Action Bigger]
Name=PokerTH Bigger
Icon=pokerth
Exec=env QT_SCALE_FACTOR=2 pokerth
Run a .desktop file from terminal
gtk-launch <file>
Where <file> is the name of the .desktop file with or without the .desktop part. The name must not include the full path.
https://askubuntu.com/questions/5172/running-a-desktop-file-in-the-terminal
Set a variable in a desktop file
Exec=env GDK_SCALE=2 mediathekview
https://askubuntu.com/questions/144968/set-variable-in-desktop-file
Documentation
https://specifications.freedesktop.org/desktop-entry/latest
XDG user directories
xdg-user-dirs is a tool to help manage “well known” user directories like the desktop folder and the music folder. It also handles localization (i.e. translation) of the filenames.
# This file is written by xdg-user-dirs-update
# If you want to change or add directories, just edit the line you're
# interested in. All local changes will be retained on the next run.
# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped
# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an
# absolute path. No other format is supported.
#
XDG_DESKTOP_DIR="$HOME/Desktop"
XDG_DOWNLOAD_DIR="$HOME/Downloads"
XDG_TEMPLATES_DIR="$HOME/Templates"
XDG_PUBLICSHARE_DIR="$HOME/Public"
XDG_DOCUMENTS_DIR="$HOME/Documents"
XDG_MUSIC_DIR="$HOME/Music"
XDG_PICTURES_DIR="$HOME/Pictures"
XDG_VIDEOS_DIR="$HOME/Videos"