I'm trying to implement the delayed hibernation unit. I'm on arch/antergos.
>>> systemctl enable suspend-to-hibernate.service
Failed to enable unit ...to-hibernate.service: Invalid argument
systemd-analyze verify ...hibernate.service responds with an empty output.
I copied the unit file straight from the arch wiki and changed SLEEPLENGTH to 1 hour. How can I debug the issue? How can I make systemd issue more descriptive error messages?
suspend-to-hibernate.service
[Unit]
Description=Delayed hibernation trigger
Documentation=https://bbs.archlinux.org/viewtopic.php?pid=1420279#p1420279
Documentation=https://wiki.archlinux.org/index.php/Power_management
Conflicts=hibernate.target hybrid-sleep.target
Before=sleep.target
StopWhenUnneeded=true
[Service]
Type=oneshot
RemainAfterExit=yes
Environment="WAKEALARM=/sys/class/rtc/rtc0/wakealarm"
Environment="SLEEPLENGTH=+1hour"
ExecStart=-/usr/bin/sh -c 'echo -n "alarm set for "; date +%%s -d$SLEEPLENGTH | tee $WAKEALARM'
ExecStop=-/usr/bin/sh -c '\
  alarm=$(cat $WAKEALARM); \
  now=$(date +%%s); \
  if [ -z "$alarm" ] || [ "$now" -ge "$alarm" ]; then \
     echo "hibernate triggered"; \
     systemctl hibernate; \
  else \
     echo "normal wakeup"; \
  fi; \
  echo 0 > $WAKEALARM; \
'
[Install]
WantedBy=sleep.target

suspend-to-hibernate.service, and have you runsystemctl daemon-reloadafter creating/modifying that file?suspend-to-hibernate.servicesits in a sub-folder of my home folder, from where I also run the commands. I was never able to enable it, so I haven't runsystemctl daemon-reload/etc/systemd/system/, and you have todaemon-reloadbefore enabling it (daemon-reloadgets systemd to recheck its directories for new or modified units, and only after than can you enable a new a service).