7

Is there a good way to automatically shutdown the Steam Deck at a specified time? On my PC I can use the Windows Scheduler to set a shutdown time and the Switch has parental controls that allow you to do the same. The Steam Deck doesn't seem to have these features though, so I've been trying to configure it via the Linux system, without any luck.

I've been trying a wide variety of variations on shutdown 22:00 with the Autostart app, but nothing seems to work. cron is not installed on the system, either.

Is there any way to have the Steam Deck automatically shutdown at a particular time?

2 Answers 2

2

Okay, after a great deal of digging, I managed to get this working. I needed to add a systemd service to run in Gaming mode. You can add an auto-start script, but that will only work in Desktop mode. So I added the following to a file /home/deck/.config/systemd/user/eveningshutdown.service:

[Unit]
Description=Evening Shutdown

[Service]
ExecStart=/usr/bin/shutdown 22:00

[Install]
WantedBy=default.target

Then run systemctl --user enable eveningshutdown.service

More useful reading in this reddit thread.

1

Yes there is also a shutdown command in Linux. You can run this, in Desktop Mode, by launching the "Konsole" application.

If you run shutdown then a shutdown will be scheduled for 60 seconds time. If you want to shutdown (much) later, then you can specify the number of minutes later. For example shutdown 120 will shut the host down in 120 minutes time.

The command doesn't support providing a time. So if you wanted the device to shut down at a specific time, you would need to work out how many minutes there are between now and the time you want it to shut down. For example, if it's 20:37 and you want it to shut down at 22:00, you would run shutdown 103.

You can also run shutdown --help to get a full list of the options:

shutdown [OPTIONS...] [TIME] [WALL...]

Shut down the system.

Options:
     --help      Show this help
  -H --halt      Halt the machine
  -P --poweroff  Power-off the machine
  -r --reboot    Reboot the machine
  -h             Equivalent to --poweroff, overridden by --halt
  -k             Don't halt/power-off/reboot, just send warnings
     --no-wall   Don't send wall message before halt/power-off/reboot
  -c             Cancel a pending shutdown

See the shutdown(8) man page for details.

As you can see, if you need to cancel the shutdown, then just use shutdown -c.

You likely could also add the "Konsole" application as a non-Steam application to Steam, so that you can launch it from Gaming mode and then run the command there.


If you mean that you want it to shutdown at 22:00 every day, then I might actually recommend against that. Shutting down isn't the same as single pressing the power button, it's a full power off. This meana that if you were in the middle of a game, any and all unsaved progress would be immediately lost; you would not power the device back on and be able to resume your game from the last state it was in.

If you really want to though, you could have the following script run at "logon", but like I mentioned, this might have some odd behaviour with sleeping, and I don't handle turning the device on after 22:00.

TODAY=$(date +%Y%m%d)
TONIGHT=$(date -d "$TODAY 22:00" +%s)
#echo $TONIGHT

NOW=$(date +%s)
#echo $NOW

DIFF=$((($TONIGHT - $NOW)/60))

#echo $DIFF

shutdown $DIFF

Don't forget to give the user permissions to execute the script with chmod u+x {filename}. So, if you placed the file in a directory called scripts in your home directory it might be:

chmod u+x ~/scripts/eveningshutdown.sh

And then you would execute the script with:

~/scripts/eveningshutdown.sh
2
  • Thanks, I'll give that a try. I'm comfortable having it be a hard shutdown at a particular time. I can set an alarm on my phone to let me know that it's going to happen soon. FYI, shutdown does allow specifying a specific time. From the man page: "The time string may either be in the format "hh:mm" for hour/minutes specifying the time to execute the shutdown at, specified in 24h clock format."
    – lobati
    Dec 19, 2022 at 18:16
  • I wanted to follow up on this. Unfortunately, it didn't work. I set up the script, made it executable with chmod +x and added it as a startup script via the Autostart options. But it doesn't work for me. I tried a variety of different variations and still couldn't get it to work.
    – lobati
    Mar 18, 2023 at 5:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .