Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to run a script on resume?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
rev138
l33t
l33t


Joined: 19 Jun 2003
Posts: 848
Location: Vermont, USA

PostPosted: Thu Mar 11, 2010 1:59 pm    Post subject: How to run a script on resume? Reply with quote

I use KDE4, and I often suspend my machine to RAM, which seems to work great. However, there is a script I would like to run automatically on resume, but I don't see any way to do that through the GUI. This has to be possible. Can anyone point me in the right direction?

Thanks.
_________________
Vermont Free PC
http://www.vtfreepc.org
Back to top
View user's profile Send private message
toralf
Advocate
Advocate


Joined: 01 Feb 2004
Posts: 2103
Location: Hamburg/Germany

PostPosted: Thu Mar 11, 2010 2:10 pm    Post subject: Re: How to run a script on resume? Reply with quote

/etc/acpi/defaults.sh contains the hook for own scripts. If you put something like
Code:
logger "before"; echo mem > /sys/power/state; logger "after"
you should see the effect.
Back to top
View user's profile Send private message
rev138
l33t
l33t


Joined: 19 Jun 2003
Posts: 848
Location: Vermont, USA

PostPosted: Fri Mar 12, 2010 12:37 am    Post subject: Reply with quote

Here's what mine looks like. Exactly where would I insert code to be run on resume?

Code:

#!/bin/sh                         
# /etc/acpi/default.sh           
# Default acpi script that takes an entry for all actions

set $*

group=${1%%/*}
action=${1#*/}
device=$2     
id=$3         
value=$4     

log_unhandled() {
        logger "ACPI event unhandled: $*"
}                                       

case "$group" in
        button)
                case "$action" in
                        power)
                                /sbin/init 0
                                ;;

                        # if your laptop doesnt turn on/off the display via hardware
                        # switch and instead just generates an acpi event, you can force
                        # X to turn off the display via dpms.  note you will have to run
                        # 'xhost +local:0' so root can access the X DISPLAY.
                        lid)
                                /usr/bin/xrandr --auto && /usr/bin/logger  Reset display resolution
                                ;;

                        *)      log_unhandled $* ;;
                esac
                ;;

        ac_adapter)
                case "$value" in
                        # Add code here to handle when the system is unplugged
                        # (maybe change cpu scaling to powersave mode).  For
                        # multicore systems, make sure you set powersave mode
                        # for each core!
                        #*0)
                        #       cpufreq-set -g powersave
                        #       ;;

                        # Add code here to handle when the system is plugged in
                        # (maybe change cpu scaling to performance mode).  For
                        # multicore systems, make sure you set performance mode
                        # for each core!
                        #*1)
                        #       cpufreq-set -g performance
                        #       ;;

                        *)      log_unhandled $* ;;
                esac
                ;;

        *)      log_unhandled $* ;;
esac


Thanks!
_________________
Vermont Free PC
http://www.vtfreepc.org
Back to top
View user's profile Send private message
ppurka
Advocate
Advocate


Joined: 26 Dec 2004
Posts: 2782

PostPosted: Fri Mar 12, 2010 1:02 am    Post subject: Re: How to run a script on resume? Reply with quote

rev138 wrote:
I use KDE4, and I often suspend my machine to RAM, which seems to work great. However, there is a script I would like to run automatically on resume, but I don't see any way to do that through the GUI. This has to be possible. Can anyone point me in the right direction?

Thanks.
If you are suspending from kde's menus then most probably pm-utils is being used in the backend. So, you can look at the documentation of pm-utils to see how you can insert your own commands before suspend and/or after resume.
_________________
emerge --quiet redefined | E17 vids: I, II
Back to top
View user's profile Send private message
toralf
Advocate
Advocate


Joined: 01 Feb 2004
Posts: 2103
Location: Hamburg/Germany

PostPosted: Fri Mar 12, 2010 8:45 am    Post subject: Reply with quote

As an example I defined a shell function suspend_to()
Code:
        button)         case $action in
                                power)  suspend_to mem
                                        ;;
which itself looks like this
Code:
function suspend_to()
{
        #       pre-down
        #
        logger "I'll go sleep"

        sync
        case $1 in
                mem)    /usr/sbin/pm-suspend
                        ;;
                disk)   /usr/sbin/pm-hibernate
                        ;;
        esac

        #       post-wakeup
        #
        logger "I'm waked up"
Back to top
View user's profile Send private message
indfodex
n00b
n00b


Joined: 13 Mar 2010
Posts: 1

PostPosted: Sat Mar 13, 2010 10:37 am    Post subject: good suggestions Reply with quote

good suggestions
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum