You are not logged in.
Pages: 1
I'd like to shutdown my computer after sleeping for a given period of time, similar to the suspend-then-hibernate option only never writing anything to the disk. I'm running arch and I'd rather not set up swap space since I have a lot of RAM and don't want to use so much disk space for it, plus I've never had any luck setting up hibernate on previous computers. Also, I rarely have anything just open that would need to be saved, usually it's just a browser, terminal windows, and a chat app, none of which are very sensitive to being rudely quit. Worst case scenario would be losing 10 minutes of work in libreoffice before it autosaved recovery information.
I've tried overriding systemd-hibernate.service to call systemd-shutdown poweroff, and I've tried changing the hibernatemode in sleep.conf to shutdown, but when I try to run hibernate (to test that it just shuts down my computer) it says there's not enough swap space, and when I try to suspend-then-hibernate it says the sleep verb is not supported. Any other ideas that might work?
~ $ /usr/bin/cat /etc/systemd/system/systemd-hibernate.service.d/override.conf
[Service]
ExecStart=
ExecStart=/usr/lib/systemd/systemd-shutdown poweroff
~ $ /usr/bin/cat /etc/systemd/sleep.conf
[Sleep]
#AllowSuspend=yes
#AllowHibernation=yes
#AllowSuspendThenHibernate=yes
AllowHybridSleep=no
SuspendMode=suspend
SuspendState=mem standby freeze
HibernateMode=shutdown
HibernateState=mem standby freeze
#HybridSleepMode=suspend platform shutdown
#HybridSleepState=disk
HibernateDelaySec=1min
~ $ systemctl hibernate
Failed to hibernate system via logind: Not enough swap space for hibernation
~ $ systemctl suspend-then-hibernate
Failed to suspend system, hibernate later via logind: Sleep verb "suspend-then-hibernate" not supportedOffline
Hi, I was trying to achieve the same as well and I finally ended with the following:
$ cat /etc/systemd/system/systemd-suspend.service
[Unit]
Description=Suspend; Shutdown if not used for a period of time
[Service]
Type=oneshot
ExecStart=/usr/local/bin/suspend-then-shutdown
$ cat /usr/local/bin/suspend-then-shutdown
#!/bin/sh
delay=$((2*3600))
start=$(date +%s)
rtcwake -s $delay -m mem
end=$(date +%s)
if [ $((end-start)) -ge $delay ]; then
systemd-run --on-active=5 systemctl poweroff
fiPlease note that I've used this on Debian 11, currently don't have Arch to test but I suppose that it should work with newer systemd as well.
Note that I've replaced (not overridden) the suspend target, not suspend-than-hibernate, which may seem more appropriate. But invoking systemctl suspend-than-hibernate is refused for me, because I use Secure Boot and lockdown mode doesn't allow hibernation.
UPDATE 2023-06-17: replaced `shutdown -h now` by `systemd-run [...] poweroff` - it seems like newer systemd doesn't allow entering shutdown when in midst of sleep target.
Last edited by MartinPulec (2023-06-17 16:46:46)
Offline
Pages: 1