| View previous topic :: View next topic |
| Author |
Message |
rev138 l33t


Joined: 19 Jun 2003 Posts: 848 Location: Vermont, USA
|
Posted: Thu Mar 11, 2010 1:59 pm Post subject: How to run a script on resume? |
|
|
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 |
|
 |
toralf Advocate


Joined: 01 Feb 2004 Posts: 2103 Location: Hamburg/Germany
|
Posted: Thu Mar 11, 2010 2:10 pm Post subject: Re: How to run a script on resume? |
|
|
/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 |
|
 |
rev138 l33t


Joined: 19 Jun 2003 Posts: 848 Location: Vermont, USA
|
Posted: Fri Mar 12, 2010 12:37 am Post subject: |
|
|
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 |
|
 |
ppurka Advocate

Joined: 26 Dec 2004 Posts: 2782
|
Posted: Fri Mar 12, 2010 1:02 am Post subject: Re: How to run a script on resume? |
|
|
| 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 |
|
 |
toralf Advocate


Joined: 01 Feb 2004 Posts: 2103 Location: Hamburg/Germany
|
Posted: Fri Mar 12, 2010 8:45 am Post subject: |
|
|
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 |
|
 |
indfodex n00b

Joined: 13 Mar 2010 Posts: 1
|
Posted: Sat Mar 13, 2010 10:37 am Post subject: good suggestions |
|
|
| good suggestions |
|
| Back to top |
|
 |
|