Freedesktop
freedesktop.org formerly X Desktop Group (XDG)
| Fedora package | Commands | Notes |
|---|---|---|
| desktop-file-utilsrpm | desktop-file-install(1), desktop-file-validate(1), update-desktop-database(1) | desktop-file-edit(1) only link on desktop-file-install
|
| xdg-user-dirsrpm | xdg-user-dir(1) (shell script), xdg-user-dirs-update(1) | |
| xdg-utilsrpm | xdg-desktop-icon(1), xdg-desktop-menu(1), xdg-mime(1), xdg-open(1), xdg-settings(1) and others xdg-* |
all xdg-* commands are shell script
|
| xdg-desktop-portalrpm | A portal frontend service for Flatpak and other desktop containment frameworks | portals.conf(5) |
basedir
Desktop base directories (basedir)
- https://www.freedesktop.org/wiki/Specifications/basedir-spec/
- https://specifications.freedesktop.org/basedir-spec
- https://wiki.archlinux.org/title/XDG_Base_Directory
| User directories | ||
| Environment variable | Dir (by default if not set) | System analogous |
|---|---|---|
XDG_CONFIG_HOME |
$HOME/.config | /etc |
XDG_CACHE_HOME |
$HOME/.cache | /var/cache |
XDG_DATA_HOME |
$HOME/.local/share | /usr/share |
XDG_STATE_HOME |
$HOME/.local/state | /var/lib |
XDG_RUNTIME_DIR |
/run/user/$UID set by pam_systemd(8) |
user runtime files (sockets, named pipes, etc.) must be owned by the user with an access mode of 0700 |
| System directories | |
| Environment variable | Dir (by default if not set) |
|---|---|
XDG_DATA_DIRS |
/usr/local/share:/usr/share |
XDG_CONFIG_DIRS |
/etc/xdg |
List of directories separated by : (analogous to PATH)
| |
User directories are more important than system. When the same information is defined in multiple places the information defined relative to the more important base directory takes precedent:
- 1st) $HOME/.local/share 2nd) /usr/local/share 3rd) /usr/share
- 1st) $HOME/.config 2nd) /etc/xdg
Each xdg-* command (bash script) from xdg-utilsrpm package uses the following lines:
search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
echo "$search"
search="${XDG_CONFIG_HOME:-$HOME/.config}:${XDG_CONFIG_DIRS:-/etc/xdg}"
echo "$search"
Desktop Entry
Desktop Entry specification describes desktop entries (configuration files) that provide information about a program, such name, icon, etc.
- https://www.freedesktop.org/wiki/Specifications/desktop-entry-spec/
- https://specifications.freedesktop.org/desktop-entry
- https://wiki.archlinux.org/title/Desktop_entries
- https://www.freedesktop.org/wiki/Howto_desktop_files/
CLI commands to launch an application: gtk-launch(1)rpm, gtk4-launch(1)rpm, gio(1)rpm or dex-autostart(1)rpm.
$ gtk-launch org.gnome.Calculator.desktop # with or without '.desktop' extension $ gio launch /usr/share/applications/org.gnome.Calculator.desktop # full path $ dex-autostart /usr/share/applications/org.gnome.Calculator.desktop # full path
[Desktop Entry]
Name=MediaInfo CLI
Type=Application
# # option 1
# Exec=sh -c "printf \\"Hello1\n\\";mediainfo --version;read -p \\"Press enter to exit\\""
# Terminal=true
# # option 2
# Exec=sh -c "printf \\"Hello2\n\\";mediainfo --version;\\$SHELL;"
# Terminal=true
# option 3
# gnome-terminal option '-e' is deprecated, use '--'
Exec=gnome-terminal -- sh -c "printf \\"Hello3\n\\";mediainfo --version;\\$SHELL;"
desktop-file-utils contains a few command line utilities for working with desktop entries. Package desktop-file-utilsrpm provides: desktop-file-edit(1), desktop-file-install(1), desktop-file-validate(1) and update-desktop-database(1).
$ desktop-file-validate $HOME/.local/share/applications/root.desktop $ desktop-file-validate /usr/local/share/applications/root.desktop
autostart
Desktop application autostart
- https://www.freedesktop.org/wiki/Specifications/autostart-spec/
- https://specifications.freedesktop.org/autostart
- https://wiki.archlinux.org/title/XDG_Autostart
By placing an application's .desktop file in one of the autostart directories the application will be automatically launched during startup of the user's desktop environment after the user has logged in. Autostart directories:
$XDG_CONFIG_HOME/autostart/($HOME/.config/autostart/ user dir by default)$XDG_CONFIG_DIRS/autostart/(/etc/xdg/autostart/ system dir by default)
$ dex-autostart --autostart --dry-run # list of all autostart programs
To disable a system entry, create an overriding entry containing Hidden=true. When the .desktop file has the Hidden key set to true, the .desktop file MUST be ignored. System desktop entries can be overridden by user desktop entries with the same filename.
Ak potrebujeme zakazat desktop application autostart napr. pre system /etc/xdg/autostart/xdg-user-dirs.desktop, vytvorime user $HOME/.config/autostart/xdg-user-dirs.desktop subor s rovnakym nazvom do ktoreho pridame Hidden=true key.
[Desktop Entry]
Type=Application
Hidden=true
NOTE Jednoduche zmazanie (alebo editovanie) suboru (napr. /etc/xdg/autostart/xdg-user-dirs.desktop) je len docasne a nevhodne riesenie. Pri dalsom system upgrade (alebo nejakej inej zmene) bude tento subor znova obnoveny.
xdg-user-dirs
xdg-user-dirs is a tool to help manage well known user directories like the Desktop folder or the Music folder.
- https://www.freedesktop.org/wiki/Software/xdg-user-dirs/
- https://wiki.archlinux.org/title/XDG_user_directories
- man pages: xdg-user-dir(1), xdg-user-dirs-update(1), user-dirs.conf(5), user-dirs.defaults(5) and user-dirs.dirs(5) (all from xdg-user-dirsrpm package)
Autostart desktop entry /etc/xdg/autostart/xdg-user-dirs.desktop pri kazdom login user spusta xdg-user-dirs-update(1). Tento program je konfigurovany systemovymi /etc/xdg/user-dirs.conf (user-dirs.conf(5)) a /etc/xdg/user-dirs.defaults (user-dirs.defaults(5)), resp. uzivatelskym $HOME/.config/user-dirs.dirs (user-dirs.dirs(5)).
Program xdg-user-dirs-update (autostart on user login) v pripade ak neexistuje subor $HOME/.config/user-dirs.dirs (napr. prve spustenie po novej instalacii) vytvori vsetky default dirs (konfiguracia v /etc/xdg/user-dirs.defaults) a zaroven vytvori aj uzivatelsky subor $HOME/.config/user-dirs.dirs. Ak uzivatel neskor vymaze niektoru nepotrebnu user dir (napr. $HOME/Music/) tak pri dalsom user login (alebo manualnom spusteni xdg-user-dirs-update) sa tato dir "vymaze" (nastavi sa na $HOME/) aj v user config file $HOME/.config/user-dirs.dirs.
$ rmdir Desktop/ Documents/ Music/ Pictures/ Public/ Templates/ Videos/ # keep only Downloads/ $ xdg-user-dirs-update
Osobne mi to pride cele zbytocne a kontraproduktivne. Zmazanie celeho package kvoli zavislostiam vsak nie je mozne. Navyse xdg-user-dirs-gtkrpm (doplnok k xdg-user-dirsrpm) ho integruje do prostredia Gnome a Gtk+ aplikacii.
icons
Icon Theme
- https://www.freedesktop.org/wiki/Specifications/icon-theme-spec/
- https://specifications.freedesktop.org/icon-theme
Icon Naming
- https://www.freedesktop.org/wiki/Specifications/icon-naming-spec/
- https://specifications.freedesktop.org/icon-naming
icon-theme contains the standard also references the default icon theme called hicolor.
On Fedora/RHEL the default dummy theme /usr/share/icons/default/index.theme inherits from the "Adwaita" theme /usr/share/icons/Adwaita/index.theme (adwaita-icon-themerpm), which in turn inherits from the "hicolor" theme /usr/share/icons/hicolor/index.theme (hicolor-icon-themerpm). The "hicolor" theme should always exist.
$ gsettings get org.gnome.desktop.interface icon-theme 'Adwaita'
Supported image file formats: PNG is the recommended bitmap format and SVG is for vectorized icons (optional). XPM is supported due to backwards compability reasons (not recommended). The extension must be .png, .svg or .xpm (lower case).
${XDG_DATA_HOME}:${XDG_DATA_DIRS}/icons/<theme>/<format>/<type>/<icon-name>
/usr/local/share/icons/hicolor/scalable/apps/root.svg
$HOME/.local/share/icons/root.svg # (don't use obsolete dir $HOME/.icons/)
xdg-utils
xdg-utils is a set of tools that allows applications to easily integrate with the desktop environment of the user, regardless of the specific desktop environment that the user runs.
- https://www.freedesktop.org/wiki/Software/xdg-utils/
- https://wiki.archlinux.org/title/Xdg-utils
- man pages: xdg-desktop-icon(1), xdg-desktop-menu(1), xdg-email(1), xdg-icon-resource(1), xdg-mime(1), xdg-open(1), xdg-screensaver(1) and xdg-settings(1) (all
xdg-*commands are shell scripts).
Fontconfig
Fontconfig is a library for configuring and customizing font access. FreeType is a TrueType font rendering library based on this configuration.
- https://www.freedesktop.org/wiki/Software/fontconfig/
- https://wiki.archlinux.org/title/Font_configuration
- man page: fonts-conf(5)rpm (or to same: https://fontconfig.pages.freedesktop.org/fontconfig/fontconfig-user.html)
- man page: FcPatternFormat(3)rpm (or to same: https://fontconfig.pages.freedesktop.org/fontconfig/fontconfig-devel/#FCPATTERNFORMAT)
- https://www.freedesktop.org/software/fontconfig/fontconfig-devel/fcpatternformat.html (to same as previous ?)
Fedora package fontconfigrpm provides many command line utilities to manage and query fonts and the font configuration of the system: fc-cache(1), fc-cat(1), fc-conflist(1), fc-list(1), fc-match(1), fc-pattern(1), fc-query(1), fc-scan(1) and fc-validate(1).
MIME
Media Types (formerly known as MIME types)
- https://wiki.archlinux.org/title/XDG_MIME_Applications
- https://en.wikipedia.org/wiki/MIME
- https://en.wikipedia.org/wiki/Media_type
- https://www.iana.org/assignments/media-types
The MIME Applications specification builds upon the shared MIME database and desktop entries to provide default applications.
- https://www.freedesktop.org/wiki/Specifications/mime-apps-spec/
- https://specifications.freedesktop.org/mime-apps-spec
- https://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec/
- https://specifications.freedesktop.org/shared-mime-info-spec
- https://www.freedesktop.org/wiki/Software/shared-mime-info/
Fedora package shared-mime-inforpm provides shared MIME info database. The database is built from the XML file /usr/share/mime/packages/freedesktop.org.xml. The files in /usr/share/mime/ should not be directly edited.
Default applications for each MIME type are stored in mimeapps.list files. The lookup order for this file is as follows:
$XDG_CONFIG_HOME/mimeapps.list |
$HOME/.config/mimeapps.list |
$XDG_CONFIG_DIRS/mimeapps.list |
/etc/xdg/mimeapps.list |
$XDG_DATA_HOME/applications/mimeapps.list |
$HOME/.local/share/applications/mimeapps.list for compatibility, deprecated |
$XDG_DATA_DIRS/applications/mimeapps.list |
/usr/local/share/applications/mimeapps.list /usr/share/applications/mimeapps.list |
and $desktop-mimeapps.list for each above locationswith higher priority |
desktop (gnome, kde, xfce, etc.) specific files /usr/share/applications/gnome-mimeapps.list |
$ XDG_UTILS_DEBUG_LEVEL=2 xdg-mime query default non/exist # discover all the files (locations) that are scanned
NOTE Files defaults.list in these locations is now obsolete, deprecated.
Fedora contains 2 mimeapps.list files:
- /usr/share/applications/gnome-mimeapps.list
- /usr/share/applications/mimeapps.list
The system-wide association between MIME types and applications is generated from the *.desktop files provided by the packages (stored in the /usr/share/applications/ directory and subdirectories) and the update-desktop-database(1)rpm parses their information and generates the /usr/share/applications/mimeinfo.cache file, that specifies for each MIME type the valid *.desktop files, i.e. applications.
$ file --mime-type screenshot.png
screenshot.png: image/png
$ xdg-mime query filetype screenshot.png
image/png
$ xdg-mime query default image/png
org.gnome.eog.
$ gio mime image/png
Default application for “image/png”: org.gnome.eog.desktop
Registered applications:
org.gnome.eog.desktop
Recommended applications:
org.gnome.eog.desktop
$ xdg-mime query default audio/mp3
audacious.desktop
$ gio mime audio/mp3
Default application for “audio/mp3”: audacious.desktop
Registered applications:
audacious.desktop
vlc.desktop
Recommended applications:
audacious.desktop
vlc.desktop
$ xdg-mime query default audio/m3u
$ gio mime audio/m3u
Default application for “audio/m3u”: audacious.desktop
Registered applications:
audacious.desktop
vlc.desktop
emacs.desktop
libreoffice-writer.desktop
Recommended applications:
audacious.desktop
vlc.desktop
NOTE Matroska audio (*.mka), resp. video (*mkv) je aktualne vo Fedora MIME info databaze ako MIME type /usr/share/mime/audio/x-matroska.xml, resp. /usr/share/mime/video/x-matroska.xml, t.j. s prefixom x-, co znamena, ze tento typ suborov nie je v registrovany v IANA databaze. Medzi tym vsak Matroska format bol zaregistrovany v ramci IANA databazy a preto je mozne predpokladat, ze v buducich verziach shared-mime-info uz budu tieto subory bez x- prefixu.
TIP Useful Perl script mimeopen(1)rpm or mimetype(1)rpm.