View Full Version : [ubuntu] Laptop - Trigger custom power management script
September 25th, 2011, 02:49 AM
Laptop - Trigger custom power management script
I wish to trigger a custom script to run when the AC power is unplugged and then when its plugged in again.
I assume there is a folder were I can place my script.
Does anyone know how I can do this?
September 25th, 2011, 04:08 AM
September 27th, 2011, 01:00 PM
Thank you for your reply.
I found what I was looking for...
# disable laptop mode, set vm parameters back to sane defaults
if state_exists laptop_mode_default; then
write_values $(restorestate laptop_mode_default)
write_values 0 10 5 500
---> insert script when on AC /folder/my_script
echo "Laptop mode disabled."
# enable laptop mode, set vm parameters to buffer as many writes as
state_exists laptop_mode_default || \
read_values | savestate laptop_mode_default
write_values "$LAPTOP_MODE" "$LAPTOP_DIRTY_RATIO" \
---> insert script when on Battery /folder/my_script
echo "Laptop mode enabled."
September 27th, 2011, 01:05 PM
September 27th, 2011, 01:55 PM
Just for sake of completeness, cpufreqd can also do that. Actually a bit more than that, because each rule can execute commands and you can have multiple rules (like AC power, AC + program XX running, battery more than x% and cpu use less than 10%, etc)
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.