Skip to content

Instantly share code, notes, and snippets.

@jvyden
Created September 1, 2023 05:47
Show Gist options
  • Select an option

  • Save jvyden/7571823a1c1b2b41786fd4e95921ab38 to your computer and use it in GitHub Desktop.

Select an option

Save jvyden/7571823a1c1b2b41786fd4e95921ab38 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
die() { echo >&2 "!! $*"; exit 1; }
# FIXME Purge old files and use this one
# File this script will modify, in addition to (potentially) the per-user sentinel file
CONF_FILE="/etc/sddm.conf.d/zz-steamos-autologin.conf"
SENTINEL_FILE="steamos-session-select"
# 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}"
session_type="x11"
session_launcher=""
create_sentinel=""
if [[ "$2" == "--sentinel-created" ]]; then
SENTINEL_CREATED=1
if [[ "$3" == "x11" ]]; then
session_type="x11"
elif [[ "$3" == "wayland" ]]; then
session_type="wayland"
fi
fi
# Update config sentinel
if [[ -z $SENTINEL_CREATED ]]; then
[[ $EUID == 0 ]] && die "Running $0 as root is not allowed"
[[ -n ${HOME+x} ]] || die "No \$HOME variable"
config_dir="${XDG_CONF_DIR:-"$HOME/.config"}"
session_type=$(
cd "$HOME"
mkdir -p "$config_dir"
cd "$config_dir"
if [[ -f "steamos-session-type" ]]; then
cp steamos-session-type "$SENTINEL_FILE"
else
echo "x11" > "$SENTINEL_FILE"
fi
cat "$SENTINEL_FILE"
)
# If we were executed as a session user and then re-execute as root below, we don't want to set root's sentinel too
export SENTINEL_CREATED=1
fi
case "$session" in
plasma-wayland-persistent)
session_launcher="plasmawayland.desktop"
;;
plasma-x11-persistent)
session_launcher="plasma.desktop"
;;
plasma)
if [[ "$session_type" == "x11" ]]; then
session_launcher="plasma-steamos-oneshot.desktop"
else
session_launcher="plasma-steamos-wayland-oneshot.desktop"
fi
create_sentinel=1
;;
gamescope)
session_launcher="gamescope-wayland.desktop"
;;
*)
echo >&2 "!! Unrecognized session '$session'"
exit 1
;;
esac
echo "Updated user selected session to $session_launcher"
# Become root
if [[ $EUID != 0 ]]; then
exec pkexec "$(realpath $0)" "$session" --sentinel-created "$session_type"
exit 1
fi
{
echo "[Autologin]"
echo "Session=$session_launcher"
} > "$CONF_FILE"
echo "Updated system autologin session to $session_launcher"
systemctl reset-failed sddm
systemctl restart sddm
echo "Restarted SDDM"
@HisDudeness3008
Copy link

Hey there! I'm trying to get my Legion GO 2 with CachyOS Handheld Edition to boot into Desktop mode (or, better, to greet me with SDDM Login Manager to let me choose which session to login into) so that I don't have to switch to Desktop Mode after SteamOS has booted up each time I fire up my machine.

From this manual, I currently should input steamos-session-select plasma-wayland-persistent, but it gives me a !! Unknown session plasma-wayland-persistent. Using a generic plasma-persistent gives the same outcome.

Note that I have a plasma.desktop in my wayland-sessions, but not a plasma-persistent or plasma-wayland-persistent. How can I get this to work? Thanks!

@jvyden
Copy link
Author

jvyden commented Feb 16, 2026

This script in particular is meant for SteamOS proper so if this isn't working for you I imagine CachyOS is doing some special things. This gist is also 3 years old so things have probably changed by then.

Either way you can probably just look at the script on your particular OS and see what options you have in the switch statement that sets the session launcher .desktop file. You can do this with the terminal command cat $(which steamos-session-select) (meaning: find the steamos-session-select executable on my computer and display the contents to my terminal)

I hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment