Last active
October 1, 2024 10:19
-
-
Save Ethorbit/725e878a04f632b7476399c5151c96e8 to your computer and use it in GitHub Desktop.
Switch Steam Deck desktop user with a single sudo command.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
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
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.