You are not logged in.
So, I return from hibernation, and there's a thing or two that I'd like to have done automatically. There are ways of doing this at the systemd level, but once xfce restarts the systemd level changes get lost. For example I always want my backup disk to be put to sleep, but it seems that when it resumes xfce always polls the disk and spins it up again. How to make the 'hdparm -y /dev/sdb' command the very last thing that happens such that xfce has finished restarting before that command is executed? There's a few other things that get lost after a resume and it would be nice to have some script or other that's always the very last thing executed. Can it be done?
Offline
Hello. Create a file /usr/lib/systemd/system-sleep/somethingsomething
with content
#!/bin/bash
case $1 in
pre)
## commands I want to do before hibernation or standby start.
/usr/bin/firstthingbeforehibernate
## add more stuff here or use &&
;;
post)
## commands I want to do after resuming from hibernation or standby.
/usr/bin/firstcommandafteresume
## add more stuff here or use && or use the "sleep" command to wait a bit first while xfce settled down
;;
esac
then chmod +x /usr/lib/systemd/system-sleep/somethingsomething
(lower case x to make it executable).
Another idea is to umount the backup disk first.
Last edited by Hussam (2019-10-21 15:48:51)
Offline
Thanks. I have no such directory. Here's anything *sleep*
/usr/lib/klibc/bin/sleep
/usr/share/hibernate/scriptlets.d/acpi_sleep
/usr/share/man/man5/systemd-sleep.conf.5.gz
/usr/share/man/man3/sleep.3.gz
/usr/share/man/man3/usleep.3.gz
/usr/share/man/man2/nanosleep.2.gz
/usr/share/man/man2/clock_nanosleep.2.gz
/usr/share/man/man1/sleep.1.gz
/usr/share/lightning/components/calSleepMonitor.manifest
/usr/share/lightning/components/calSleepMonitor.js
/lib/systemd/system/systemd-hybrid-sleep.service
/lib/systemd/system/sleep.target
/lib/systemd/system/hybrid-sleep.target
/lib/systemd/systemd-sleep
/bin/sleep
Here's anything *hibernate*:
files:
/usr/sbin/hibernate
/usr/share/icons/hicolor/48x48/apps/system-hibernate.png
/usr/share/icons/hicolor/48x48/apps/xfsm-hibernate.png
/usr/share/doc/hibernate/examples/hibernate.vim.gz
/usr/share/man/man5/hibernate.conf.5.gz
/usr/share/man/man8/systemd-hibernate-resume@.service.8.gz
/usr/share/man/man8/systemd-hibernate-resume-generator.8.gz
/usr/share/man/man8/hibernate.8.gz
/usr/share/bash-completion/completions/pm-hibernate
/var/log/hibernate.log.5
/var/log/hibernate.log.1
/var/log/hibernate.log
/var/log/hibernate.log.2
/var/log/hibernate.log.3
/var/log/hibernate.log.4
/var/lib/dpkg/info/hibernate.postinst
/var/lib/dpkg/info/hibernate.conffiles
/var/lib/dpkg/info/hibernate.preinst
/var/lib/dpkg/info/hibernate.postrm
/var/lib/dpkg/info/hibernate.md5sums
/var/lib/dpkg/info/hibernate.prerm
/var/lib/dpkg/info/hibernate.list
/lib/systemd/system-generators/systemd-hibernate-resume-generator
/lib/systemd/systemd-hibernate-resume
/lib/systemd/system/systemd-hibernate.service
/lib/systemd/system/hibernate.target
/lib/systemd/system/systemd-hibernate-resume@.service
/etc/hibernate/hibernate.conf
/etc/logrotate.d/hibernate
directories:
/usr/local/share/hibernate
/usr/share/hibernate
/usr/share/doc/hibernate
/usr/share/bug/hibernate
/var/lib/systemd/deb-systemd-helper-enabled/hibernate.target.wants
/etc/hibernate
/etc/systemd/system/hibernate.target.wants
Systemd doesn't make things simple, does it?
Last edited by rayandrews (2019-10-21 16:55:56)
Offline
Which systemd version are you using?
Systemd configuration depends on the distribution to be fair. Stock systemd installations work best.
I am afraid I am not sure how Debian implements it as I have not used Debian or one of its derivatives in the past decade.
However, since Debian is one of the prominent distributions, what I would do in this case is consult Debian support on how to add "sleep hooks" in their systemd installation. Perhaps they offer some documentation.
Offline
@OPs seems to be located at /lib/systemd/systemd-sleep.
Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
Which systemd version are you using?
Systemd configuration depends on the distribution to be fair. Stock systemd installations work best.
I am afraid I am not sure how Debian implements it as I have not used Debian or one of its derivatives in the past decade.
However, since Debian is one of the prominent distributions, what I would do in this case is consult Debian support on how to add "sleep hooks" in their systemd installation. Perhaps they offer some documentation.
Yep, it's Debian. But I do recall trying this before, and I did figure out the 'sleep hooks' but it didn't work anyway. Xfce seemed to always spin up the disks regardless. Dunno, maybe I should try again. As for systemd, I can't say I love it, they seem to go out of their way to make things more complicated than the tax code.
Offline
Got it:
file is /etc/hibernate/common.conf :
>### misclaunch
>OnSuspend 20 echo "Good night!"
>OnResume 20 echo "Good morning!"
>OnResume 21 hdparm -S60 /dev/sdb; hdparm -C /dev/sdb; hdparm -y /dev/sdb
>OnResume 22 . /aWorking/Zsh/System/mouse
... spins down my 2nd disk, and resets my mouse parameters (which are also lost on resume). One of the two dozen or so possible files had to work ;-)
Thanks guys.
Last edited by rayandrews (2019-10-22 15:21:36)
Offline
[ Generated in 0.010 seconds, 8 queries executed - Memory usage: 548.35 KiB (Peak: 549.2 KiB) ]