# Start the XDG autostart entries meant for this session, as the XDG Autostart # spec reads them. An entry is skipped when Hidden=true, when OnlyShowIn names # no desktop in $XDG_CURRENT_DESKTOP, when NotShowIn names one, or when its # TryExec program is not found. Only the [Desktop Entry] group is read. XDGAUTOSTART=${XDGAUTOSTART:-/etc/xdg/autostart} xdg_autostart_key() { sed -n -e '/^\[Desktop Entry\]/,/^\[/!d' \ -e "s/^$2[[:space:]]*=[[:space:]]*//p" "$1" | head -n 1 } xdg_autostart_wanted() { [ "$(xdg_autostart_key "$1" Hidden)" = true ] && return 1 xdg_only=$(xdg_autostart_key "$1" OnlyShowIn) xdg_not=$(xdg_autostart_key "$1" NotShowIn) xdg_shown=yes [ -n "$xdg_only" ] && xdg_shown=no for xdg_de in $(echo "$XDG_CURRENT_DESKTOP" | tr ':' ' '); do case ";$xdg_not;" in *";$xdg_de;"*) return 1 ;; esac case ";$xdg_only;" in *";$xdg_de;"*) xdg_shown=yes ;; esac done [ "$xdg_shown" = yes ] || return 1 xdg_tryexec=$(xdg_autostart_key "$1" TryExec) [ -z "$xdg_tryexec" ] || command -v "$xdg_tryexec" >/dev/null 2>&1 } if [ -d "$XDGAUTOSTART" ]; then for SCRIPT in "$XDGAUTOSTART"/*.desktop; do [ -f "$SCRIPT" ] || continue xdg_autostart_wanted "$SCRIPT" || continue CMD=$(xdg_autostart_key "$SCRIPT" Exec) [ -n "$CMD" ] && $CMD & done fi unset -f xdg_autostart_key xdg_autostart_wanted unset xdg_only xdg_not xdg_shown xdg_de xdg_tryexec