[Solved] How run a script on wake up?

Kernels & Hardware, configuring network, installing services

[Solved] How run a script on wake up?

Postby bester69 » 2019-01-12 16:12

Hi,

I need some help, I took a look at internet seeking for this, but I didnt find much very good information about it, I tried some proposals solutions but they didnt work at all, so I came here for some help of you, I know this mustn't be any difficult, so where and How do I have to go about setting thoses scripts in order to be launching on waking up or/and on suspending the system.


Thanks a lot.
Last edited by bester69 on 2019-01-12 23:54, edited 1 time in total.
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1413
Joined: 2015-04-02 13:15

Re: How run a script on wake up?

Postby bw123 » 2019-01-12 17:56

Ways I can think of off the top of my head..
/lib/systemd/system-sleep - check man systemd-sleep
/usr/lib/pm-utils/sleep.d or /etc/pm - might or might not need pm-utils pkg
/etc/acpi - catch a lid or power event, probably some examples there already
use laptop-mode or some other power mgr, not too difficult.

If you post the script, or describe it, there might be a reason to use one or the other or none of the above.
User avatar
bw123
 
Posts: 3787
Joined: 2011-05-09 06:02

Re: How run a script on wake up?

Postby Head_on_a_Stick » 2019-01-12 18:18

bester69 wrote:I tried some proposals solutions but they didnt work at all

If you state explicitly what you have already tried then it will stop people wasting your time by posting suggestions you have already attempted.

And without posting your exact method we have no way of knowing if you're doing it right.

Take a look at an example unit file I posted over at the ArchLabs forums, that runs when resuming from suspend or hibernate:

https://forum.archlabslinux.com/t/how-t ... ed/2065/45

^ The key is the WantedBy line ;)
User avatar
Head_on_a_Stick
 
Posts: 10368
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: How run a script on wake up?

Postby bester69 » 2019-01-12 23:53

Ok, I found out the problem is, I was using pm-suspend for suspending system, so It cant trigger thes scripts by using pm-suspend.

The Solution was using systemctl suspend
.:
>> systemctl suspend
Code: Select all
sudo tee /lib/systemd/system-sleep/wakeup_script <<'EOB'
#!/bin/sh
case $1 in
    post)
        #COMMANDS GO HERE
        ;;
esac
EOB


Thanks for your help.
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1413
Joined: 2015-04-02 13:15


Return to System configuration

Who is online

Users browsing this forum: No registered users and 9 guests

fashionable