You are not logged in.
I can't seem to figure out how to make it so when I unplug the AC power source from my laptop commands are run that change the cpufreq governor and change the brightness with nvclock.
Specifically, I want to have my laptop running cpufreq as ondemand while on AC power and powersave while on Battery power. I also want the command
nvclock -S 30
to be run when the AC is unplugged. Then, when it's plugged in again, I want this run:
nvclock -S 90
This is my /etc/acpi/handler.sh. I've been experimenting with it and following numerous guides and tips I've googled, I've read as much as I can about laptops and acpi in the arch wiki, but I just can't seem to get these commands run properly.
#!/bin/sh
# Default acpi script that takes an entry for all actions
# NOTE: This is a 2.6-centric script. If you use 2.4.x, you'll have to
# modify it to not use /sys
minspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq`
maxspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`
setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"
set $*
case "$1" in
button/power)
#echo "PowerButton pressed!">/dev/tty5
case "$2" in
PWRF) logger "PowerButton pressed: $2" ;;
*) logger "ACPI action undefined: $2" ;;
esac
;;
button/sleep)
case "$2" in
SLPB) echo -n mem >/sys/power/state ;;
*) logger "ACPI action undefined: $2" ;;
esac
;;
ac_adapter)
case "$2" in
AC)
case "$4" in
00000000)
echo "powersave" >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo -n $minspeed >$setspeed
nvclock -S 30
#/etc/laptop-mode/laptop-mode start
;;
00000001)
echo "ondemand" >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo -n $maxspeed >$setspeed
nvclock -S 90
#/etc/laptop-mode/laptop-mode stop
;;
esac
;;
*) logger "ACPI action undefined: $2" ;;
esac
;;
battery)
case "$2" in
BAT0)
case "$4" in
00000000) #echo "offline" >/dev/tty5
;;
00000001) #echo "online" >/dev/tty5
;;
esac
;;
CPU0)
;;
*) logger "ACPI action undefined: $2" ;;
esac
;;
button/lid)
#echo "LID switched!">/dev/tty5
;;
*)
logger "ACPI group/action undefined: $1 / $2"
;;
esac
I would think the ac_adapter) part is the most relevant, but I posted the whole thing just in case something else needed to be done.
Thanks for any help. Also, if there's a better way to accomplish the same thing, please let me know.
P.S. I have laptop-mode-tools installed, but there is very little documentation and following forum posts to try to find what I want is more difficult than I thought. If posting any config files relating to that would help, I'll do that too.
Last edited by Allamgir (2009-07-05 00:33:10)
дɭɭɑӎɠїɾ
Offline
Do that all with laptop-mode-tools. Every config file is full of comments.
Cpufreq is set in /etc/laptop-mode/conf.d/cpufreq.conf. Also I recommend you conservative governor, instead of powersave, it's much better.
Any executable scripts can be run, and set, with /etc/laptop-mode/conf.d/start-stop-programs.conf.
Hope that helped
Last edited by vi3dr0 (2009-07-03 18:55:11)
Thinkpad T61p : T7700 | 4GB RAM | nVidia FX 570M | Intel 4965
Arch64 @ Openbox
Offline
Thanks for the help! I got my cpufreq governors changing properly
but I don't know how to write shell scripts, so I did the brightness part wrong. I created the directories batt-start, batt-stop, lm-ac-stop, &c. and I put in a couple of .sh files that just have the commands to change the brightness. For example, here's /etc/laptop-mode/batt-start/brightness-low.sh:
nvclock -S 30
...which will set the brightness at 30%. I have one in /etc/laptop-mode/nolm-ac-start called brightness-high that changes the brightness to 90%. If I run the scripts with the command line, for example
$ sh /etc/laptop-mode/batt-start/brightness-low.sh
Then my brightness is set to 30%, just how I want it. Putting these scripts in those directories and making sure the value for CONTROL_START_STOP is 1 does not do anything. Do I put the directory to the script in the BATT_START option in the start-stop-programs.conf file or is there something else that I'm doing wrong.
Hopefully that wasn't too much of a mouthful. I know the commands, but don't know how to put them into proper script/service/whateverlaptopmodewants format so laptop-mode uses it.
дɭɭɑӎɠїɾ
Offline
To be honest, I never used this feature - I control brightness with KDE power manager
However I suppose it's something with "Put scripts accepting "start" and "stop" parameters in the directions...". I'll play with it a bit...
Thinkpad T61p : T7700 | 4GB RAM | nVidia FX 570M | Intel 4965
Arch64 @ Openbox
Offline
Thanks. I'm completely lost here.
дɭɭɑӎɠїɾ
Offline
So I finally put together some scripts with the help of google that work properly with start/stop, but laptop-mode-tools doesn't use it for some reason. Here is the script I put in /etc/laptop-mode/batt-start called brightness.sh:
case "$1" in
'start')
sh /home/agi/.bin/brightness-low.sh
;;
'stop')
sh /home/agi/.bin/brightness-high.sh
;;
'restart')
echo "Usage: $0 [start|stop]""
;;
esac
What this does is run scripts that change the brightness found in my ~/.bin directory with start (to lower brightness) and stop (to raise it again). Here is brightness-low.sh:
nvclock -S 30
as you can see it's very simple. Just the command. brightness-high.sh is similar:
nvclock -S 90
Now, the strange part is that if I run brightness.sh in a terminal, it works perfectly:
$ sh /etc/laptop-mode/batt-start/brightness.sh start
Changing Smartdimmer level from 25% to 30%
New Smartdimmer level: 30%
$ sh /etc/laptop-mode/batt-start/brightness.sh stop
Changing Smartdimmer level from 30% to 90%
New Smartdimmer level: 90%
I only put my brightness.sh script in batt-start and not nolm-ac-stop or anything because the config file says anything in *-start will be started on entry into the state and stopped on exit.
Now I'm completely confused. It seems as if I've done all I know to get this to work, rebooted every time, yet when I unplug my laptop, the brightness remains the same.
дɭɭɑӎɠїɾ
Offline
Is your script executable?
If not you can change this with the chmod command.
hightower
Offline
It's so simple I almost want to cry.
BUT IT WORKS! YES!!!!!
Thank you all so much for all of your help. I now have laptop-mode-tools set up to my liking!
Thread [SOLVED]
дɭɭɑӎɠїɾ
Offline
Sorry that I'm refreshing such old topic (and sorry about my english ), but I've exactly the same problem. I've created a simple script:
#!/bin/bash
case "$1" in
'start')
xfwm4 --replace --compositor=off
;;
'stop')
xfwm4 --replace --compositor=on
;;
esac
exit
I've used chmod 755 on it, and placed it in batt-start folder. It works perfectly only when I start it as normal user manually. Why it doesn't work with batt-start folder? How can I check if laptop mode tools responds correctly to changing power supply (battery/ac)??
Last edited by maci3k (2011-02-19 16:33:29)
Offline