Skip to content

Instantly share code, notes, and snippets.

@Ethorbit
Last active April 2, 2024 13:49
Show Gist options
  • Save Ethorbit/725e878a04f632b7476399c5151c96e8 to your computer and use it in GitHub Desktop.
Save Ethorbit/725e878a04f632b7476399c5151c96e8 to your computer and use it in GitHub Desktop.
Switch Steam Deck desktop user with a single sudo command.
#!/bin/bash
user="$1"
if ! [[ `id "$user" 2> /dev/null` ]]; then
echo "Not a valid user" 1>&2 && exit 1
fi
if [[ `echo "$user" | grep "|"` ]]; then
echo "Username cannot have '|'" 1>&2 && exit 1
fi
if [[ `grep "User=$user" /etc/sddm.conf.d/steamos.conf` ]]; then
echo "User already set" 1>&1 && exit
fi
sed -i "s|^User=.*|User=$user|" /etc/sddm.conf.d/steamos.conf
/sbin/systemctl restart sddm
@Ethorbit
Copy link
Author

Ethorbit commented Mar 28, 2023

Usage: sudo switch-session-user.sh username

Every desktop user will have an entirely different Steam install, so prepare to waste space. It makes it easy to share your deck with other people though.

@Ethorbit
Copy link
Author

If you want to force a specific user on boot, you can create a systemd service:
/etc/systemd/system/default-session-user.service

[Unit]
Description=Sets a default session user

[Service]
Type=oneshot
ExecStart=/bin/bash /path/to/switch-session-user.sh username

[Install]
WantedBy=multi-user.target

sudo systemctl enable default-session-user.service

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