#!/bin/sh
# Creates an "Install SolydXK" icon on the live session tested with:
# Xfce, LXDE, LXqt, Gnome, KDE, Mate, Cinnamon

# We query xdg-user-dir because the Desktop directory has different
# names for different languages
DESKTOP=$(xdg-user-dir DESKTOP)

# Create ~/Desktop just in case this runs before the xdg folder
# creation script.
mkdir -p $DESKTOP

# Among the SolydXK desktop environments, LXDE is the only one
# that behaves completely different.
if [ -f /usr/bin/lxsession ]; then
    cat > $DESKTOP/install-solydxk.desktop << EOF
[Desktop Entry]
Type=Link
Name=Install SolydXK
Icon=install-solydxk
URL=/usr/share/applications/install-solydxk.desktop
EOF
else
    #ln -s /usr/share/applications/install-solydxk.desktop $DESKTOP
    cp /usr/share/applications/install-solydxk.desktop $DESKTOP
    # Xfce: prevent Untrusted Application Launcher dialog
    chmod g+w,a+x $DESKTOP/install-solydxk.desktop
    gio set -t string "$DESKTOP/install-solydxk.desktop" metadata::xfce-exe-checksum "$(sha256sum $DESKTOP/install-solydxk.desktop | awk '{print $1}')"
    gio set -t string "$DESKTOP/install-solydxk.desktop" metadata::trust "true"
fi
