Page 1 of 1

[SOLVED]run script on wake up from sleep

PostPosted: May 13th, '23, 16:10
by nexus
Hello,
what is right way to run script on wake up from sleep on Mageia 5?
I created a script named 99test
Code: Select all
#!/bin/sh

case "$1" in
   hibernate|suspend)
      ;;
   thaw|resume)
      touch /home/test.txt
      ;;
   *) exit $NA
      ;;
esac

and I put it in two places:
/usr/lib64/pm-utils/sleep.d/
and
/etc/pm/sleep.d/
but without success. File test.txt not was created after wake up from sleep.

Re: run script on wake up from sleep

PostPosted: May 13th, '23, 18:26
by morgano
This question is not my cup of tea.

But why are you on Mageia *5* ?
It is since long not supported.

Re: run script on wake up from sleep

PostPosted: May 13th, '23, 22:08
by nexus
Mageia 5 is the last version that has the functionality what I need (more here viewtopic.php?f=7&t=14188).
But maybe the same method will work like in Mageia 8.

Re: run script on wake up from sleep

PostPosted: May 14th, '23, 16:19
by doktor5000

Re: run script on wake up from sleep

PostPosted: May 15th, '23, 00:19
by nexus
I created file:
/etc/systemd/system/root-resume.service
Code: Select all
[Unit]
Description=Local system resume actions
After=suspend.target

[Service]
Type=simple
ExecStart=/bin/touch /home/test.txt

[Install]
WantedBy=suspend.target
run command:
systemctl enable root-resume.service
and... it work.
Thank you very much

Re: run script on wake up from sleep

PostPosted: May 15th, '23, 16:14
by doktor5000
Please don't forget to mark the thread as solved, by editing the subject of the first post and prefix it with [SOLVED], thanks in advance.