59 lines
1.3 KiB
Bash
Executable file
59 lines
1.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
die() { echo >&2 "!! $*"; exit 1; }
|
|
|
|
# File this script will modify
|
|
CONF_FILE="/etc/sddm.conf.d/zz-steamos-autologin.conf"
|
|
|
|
# For sanity this shipped file must be present, to ensure we're still on a normal-looking steamos setup.
|
|
CHECK_FILE="/etc/sddm.conf.d/steamos.conf"
|
|
|
|
session="${1:-gamescope}"
|
|
|
|
# Become root
|
|
if [[ $EUID != 0 ]]; then
|
|
pkexec "$(realpath $0)" "$session" --sentinel-created
|
|
# Quit existing sessions
|
|
if [[ "$2" != "--no-restart" ]]; then
|
|
systemctl --user --no-block stop gamescope-session.service
|
|
systemctl --user --no-block stop plasma-workspace.target
|
|
fi
|
|
exit
|
|
fi
|
|
|
|
if [[ "$2" != "--sentinel-created" ]]; then
|
|
die "Running $0 as root is not allowed"
|
|
fi
|
|
|
|
session_launcher=""
|
|
|
|
case "$session" in
|
|
plasma-wayland-persistent)
|
|
session_launcher="plasma.desktop"
|
|
;;
|
|
plasma-x11-persistent)
|
|
session_launcher="plasmax11.desktop"
|
|
;;
|
|
plasma)
|
|
session_launcher="xfce4-steamos-oneshot.desktop"
|
|
;;
|
|
plasma-wayland)
|
|
session_launcher="plasma-steamos-wayland-oneshot.desktop"
|
|
;;
|
|
gamescope)
|
|
session_launcher="gamescope-wayland.desktop"
|
|
;;
|
|
*)
|
|
echo >&2 "!! Unrecognized session '$session'"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
echo "Updated user selected session to $session_launcher"
|
|
|
|
{
|
|
echo "[Autologin]"
|
|
echo "Session=$session_launcher"
|
|
} > "$CONF_FILE"
|