#!/usr/bin/sh
#
# live-lxqt: lxqt specific setup for livesys
# SPDX-License-Identifier: GPL-3.0-or-later
#


# determine if wayland session is available
if $(rpm -q lxqt-wayland-session > /dev/null 2>&1) ; then
  DEFAULT_DESKTOP="lxqt-wayland.desktop"
else
  DEFAULT_DESKTOP="lxqt.desktop"
fi

# set up autologin for user liveuser
if [ -f /etc/sddm.conf ]; then
sed -i 's/^#User=.*/User=liveuser/' /etc/sddm.conf
sed -i "s/^#Session=.*/Session=${DEFAULT_DESKTOP}/" /etc/sddm.conf
else
cat > /etc/sddm.conf << SDDM_EOF
[Autologin]
User=liveuser
Session=${DEFAULT_DESKTOP}
SDDM_EOF
fi

# show liveinst.desktop on desktop and in menu
sed -i 's/NoDisplay=true/NoDisplay=false/' /usr/share/applications/liveinst.desktop
mkdir /home/liveuser/Desktop
cp -a /usr/share/applications/liveinst.desktop /home/liveuser/Desktop/
# Enable metadata::trust so the .desktop file for anaconda is launchable, see: https://pagure.io/fedora-lxqt/SIG/issue/5
chmod +x /home/liveuser/Desktop/liveinst.desktop
gio set /home/liveuser/Desktop/liveinst.desktop metadata::trust true

# set up preferred apps
cat > /etc/xdg/libfm/pref-apps.conf << FOE
[Preferred Applications]
WebBrowser=qupzilla.desktop
FOE

# no updater applet in live environment
rm -f /etc/xdg/autostart/org.mageia.dnfdragora-updater.desktop
