When going to sleep at night i like to put on a movie or serie on my steamdeck. I wanted the steamdeck to suspend after a variable amount of time. So i created a little bash script with a desktop file to do this. The desktop file goes on your desktop so you can click it, it pops up a window asking in how many minutes the steamdeck should suspend and after that it will sleep until the time has passed so you can just put it in the background and fullscreen your movie and fall asleep. I thought i’d share my little hacked together script so other people can benefit too.
The file to put on your desktop (sleep.desktop):
[Desktop Entry]
Comment=
Encoding=UTF-8
Exec=/home/deck/scripts/sleep.sh
GenericName=
Name=Sleep
StartupNotify=true
Terminal=true
Type=Application
The /home/deck/scripts/sleep.sh script:
#!/bin/bash
VALUE=`zenity --scale --text="How many minutes before steamdeck suspends?" --min-value=10 --value=60 --step=10 --max-value=240`
case $? in
0)
seconds=$((VALUE * 60))
echo "Sleeping $seconds seconds ($VALUE minutes)...."
sleep $seconds
echo "Suspending..."
sudo systemctl suspend;;
1)
echo "No value selected.";;
-1)
echo "An unexpected error has occurred.";;
esac
To allow deck to run systemctl without sudo password add this to your sudo file:
deck ALL=NOPASSWD: /usr/bin/systemctl
Why are you using the Jellyfin icon?
Because i mainly use jellyfin to watch series and movies. Removed it in this post tho, so you can choose your own icon :)