core-agent-linux/misc/qubes-trigger-desktop-file-install
Jason Mehring b6c19fc2ef qubes-desktop-file-install: Manages xdg desktop entry files
qubes-desktop-file-install is called by qubes-triggers-desktop-file-install. It's
arguments are based on the Gnome desktop-install-file utility to allow it to be replaced
by same.  Currently the Gnome utility can not be used since it automatically validates
the .desktop entry files with no option to skip validation and will fail on some third
party .desktop files that are not formed properly.

A single trigger script is shared between Fedora, Debian.  This script is used by the
package managers triggers and will copy original .desktop files from `/etc/xdg/autostart`
to `/usr/share/qubes/xdg/autostart` and modify the OnlyShownIn / NotShownIn, etc.  The
original .desktop files are left untouched and left in place.

Qubes modifies the XDG_CONFIG_DIRS to first include the `/usr/share/qubes/xdg`
directory (XDG_CONFIG_DIRS=/usr/share/qubes/xdg:/etc/xdg).

If a package gets removed, it's desktop entry is also removed from the /usr/share/qubes/xdg
directory.

'qubes-desktop-file-install' options:
   --dir DIR                          Install desktop files to the DIR directory (default: <FILE>)
   --force                            Force overwrite of existing desktop files (default: False)
   --remove-show-in                   Remove the "OnlyShowIn" and "NotShowIn" entries from the desktop file (default: False)
   --remove-key KEY                   Remove the KEY key from the desktop files, if present
   --set-key (KEY VALUE)              Set the KEY key to VALUE
   --remove-only-show-in ENVIRONMENT  Remove ENVIRONMENT from the list of desktop environment where the desktop files should be displayed
   --add-only-show-in ENVIRONMENT     Add ENVIRONMENT to the list of desktop environment where the desktop files should be displayed
   --remove-not-show-in ENVIRONMENT   Remove ENVIRONMENT from the list of desktop environment where the desktop files should not be displayed
   --add-not-show-in ENVIRONMENT      Add ENVIRONMENT to the list of desktop environment where the desktop files should not be displayed
2015-08-07 09:15:30 -04:00

98 lines
3.3 KiB
Bash
Executable File

#!/bin/bash -e
# vim: set ts=4 sw=4 sts=4 et :
#
# qubes-trigger-desktop-file-install
#
# This trigger script calls qubes-desktop-file-install to installation and edit
# desktop file overrides, leaving the original desktop file in-place and
# untouched.
#
# 'qubes-desktop-file-install' options:
# --dir DIR Install desktop files to the DIR directory (default: <FILE>)
# --force Force overwrite of existing desktop files (default: False)
# --remove-show-in Remove the "OnlyShowIn" and "NotShowIn" entries from the desktop file (default: False)
# --remove-key KEY Remove the KEY key from the desktop files, if present
# --set-key (KEY VALUE) Set the KEY key to VALUE
# --remove-only-show-in ENVIRONMENT Remove ENVIRONMENT from the list of desktop environment where the desktop files should be displayed
# --add-only-show-in ENVIRONMENT Add ENVIRONMENT to the list of desktop environment where the desktop files should be displayed
# --remove-not-show-in ENVIRONMENT Remove ENVIRONMENT from the list of desktop environment where the desktop files should not be displayed
# --add-not-show-in ENVIRONMENT Add ENVIRONMENT to the list of desktop environment where the desktop files should not be displayed
QUBES_DESKTOP_FILE_INSTALL='/usr/bin/qubes-desktop-file-install'
QUBES_XDG_CONFIG_DIR=/usr/share/qubes/xdg/autostart
XDG_CONFIG_DIR=/etc/xdg/autostart
INSTALL_CMD=""${QUBES_DESKTOP_FILE_INSTALL}" --force --dir "${QUBES_XDG_CONFIG_DIR}""
# Remove all current Qubes desktop entry files
if [ "${1}" == "clean" ]; then
rm -f "${QUBES_XDG_CONFIG_DIR}"/*
fi
generatePath () {
echo "${XDG_CONFIG_DIR}/${1}.desktop"
}
generateFileList () {
for key in "${!FILES[@]}"; do
FILES[${key}]="$(generatePath ${FILES[key]})"
done
}
install () {
local options="${@}"
# Install an edited version of desktop file in $QUBES_XDG_CONFIG_DIR
generateFileList
$INSTALL_CMD "${@}" "${FILES[@]}" || true
}
# Desktop Entry Modification - NotShowIn=QUBES
FILES=(
'pulseaudio'
'deja-dup-monitor'
'imsettings-start'
'krb5-auth-dialog'
'restorecond'
'sealertauto'
'gnome-power-manager'
'gnome-sound-applet'
'gnome-screensaver'
'orca-autostart'
); install --remove-show-in --add-not-show-in X-QUBES
# Desktop Entry Modification - NotShowIn=DisposableVM
FILES=('gcm-apply')
install --remove-show-in --add-not-show-in X-DisposableVM
# Desktop Entry Modification - OnlyShowIn=GNOME;AppVM;
FILES=(
'gnome-keyring-gpg'
'gnome-keyring-pkcs11'
'gnome-keyring-secrets'
'gnome-keyring-ssh'
'gnome-settings-daemon'
'user-dirs-update-gtk'
'gsettings-data-convert'
); install --remove-show-in --add-only-show-in 'GNOME;X-AppVM'
# Desktop Entry Modification - OnlyShowIn=GNOME;UpdateableVM
FILES=('gpk-update-icon')
install --remove-show-in --add-only-show-in 'GNOME;X-UpdateableVM'
# Desktop Entry Modification - OnlyShowIn=GNOME;QUBES
FILES=('nm-applet')
install --remove-show-in --add-only-show-in 'GNOME;X-QUBES'
# Desktop Entry Modification - Remove existing rules
FILES=(
'abrt-applet'
); install --remove-show-in
# Desktop Entry Modification - Misc
# notify-osd
$INSTALL_CMD --remove-show-in --remove-key X-GNOME-Autostart-enabled "$(generatePath notify-osd)"