LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   How to Run a Script on wake up from Sleep state (https://www.linuxquestions.org/questions/slackware-14/how-to-run-a-script-on-wake-up-from-sleep-state-940311/)

bogzab 04-17-2012 02:55 PM

How to Run a Script on wake up from Sleep state
 
I want to be able to run a short script (which turns of the touchpad on my Thinkpad laptop, leaving just the trackpoint device working). I have the script and it works fine, but I have to run it manually every time I bring the machine back from sleep because it seems to always come up with the touchpad on.

Is there a place where such a script file should go to be executed automagically on return from sleep?

(Usually I am putting the PC to sleep via the KDE "Leave" Menu and waking it up just by opening the lid)

Thanks

BCarey 04-17-2012 04:18 PM

You can put your scripts in /etc/pm/sleep.d. There are a lot of scripts in /usr/lib/pm-utils/sleep.d that you can look at to find out how to make your script run on resume.

Brian

marrowsuck 04-17-2012 04:20 PM

When the computer wakes up from hibernate or suspend all scripts in
/etc/pm/sleep.d are called in reversed order with the argument "thaw" or "resume".

Just put something like
Code:

#!/bin/sh
case "$1" in
    thaw|resume)
        yourscript.sh
        ;;
esac

in /etc/pm/sleep.d and you should be fine.

For more information see man pm-action.

bogzab 04-18-2012 02:54 PM

This solution is not working for me in this case. I think that it might be because the scripts in /etc/pm/sleep.d are run before the X session is back up and running. To execute my "touchpad-off" script I think the X session has to be active.

Perhaps what I need is a place to store scripts which will run on commencement of an X session?

marrowsuck 04-18-2012 06:58 PM

Prepend your wrapperscript in /etc/pm/sleep.d with a low number e.g. 01wrapperscript,
so that it's called at the end.

How did you disable your touchpad in the first place?
Maybe it would be more convenient to disabled it through X with a configfile in /etc/X11/xorg.conf.d.
If you're using the synapitcsdriver just copy /usr/share/X11/xorg.conf.d/50-synaptics.conf to
/etc/X11/xorg.conf.d and insert the line
Code:

Option "TouchpadOff" "1"

bogzab 04-19-2012 04:00 PM

Tried the low number pre-pend but no joy.
However the X11 config solution worked fine - many thanks for this. Should have been obvious to me in the first place.


All times are GMT -5. The time now is 06:39 AM.