Since upgrade from 14.10 to 15.04 my custom script which I used to setup proper thermal profile mode for my laptop ceased to work, which I believe is because pm-utils do not respond to AC/BAT switching.

Now, if that is new intended behavior of the system, where now should I put my script to do that job (required for my laptop to run properly even on AC power)?

  • A related question is askubuntu.com/q/609695/43344 . – JdeBP Apr 25 '15 at 8:58
  • Arch Wiki says: "systemd cannot handle AC and Battery ACPI events, so if you use Laptop Mode Tools or other similar tools acpid is still required.". So, it may not be related to systemd directly. – dilettant Apr 25 '15 at 10:37

Ok, found an answer in Arch Wiki. They give the next solution:

There is just one thing systemd cannot do (as of systemd-204): power management depending on whether the system is running on AC or battery. To fill this gap, you can create a single udev rule that runs a script when the AC adapter is plugged and unplugged:

SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="/path/to/your/script true"
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/path/to/your/script false"

For my Sony Vaio, I have this as my personal setup:


SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="/usr/local/bin/sony-thermal.sh true"
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/usr/local/bin/sony-thermal.sh false"



help() {
    cat <<EOF
$0: SONY laptop thermal profile management

This script selects between "performance" and "silent" modes depending
on whether laptop runs on AC power or battery power.


set_sony_thermal_profile() {
    [ ! -d /sys/devices/platform/sony-laptop ] && exit $NA
    [ ! -f /sys/devices/platform/sony-laptop/thermal_control ] && exit $NA
    case $1 in
        printf "Setting SONY thermal control to performace mode."
        thermal_control=performance ;;
        printf "Setting SONY thermal control to silent mode."
        thermal_control=silent ;;
        printf "Setting SONY thermal control to balanced mode."
        thermal_control=balanced ;;
    echo "$thermal_control" > /sys/devices/platform/sony-laptop/thermal_control && echo Done. || \
    echo Failed.

case $1 in
    true) set_sony_thermal_profile silent ;;
    false) set_sony_thermal_profile performance ;;
    help) help ;;
    *) exit $NA ;;

exit 0

This prevents CPU in my notebook to go into "throttling" continuously even at light loading conditions with great performance and user experience losses.

| improve this answer | |

Default Ubuntu power scripts can be triggered this way.

Add a file pm-utils with this content

SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="/usr/sbin/pm-powersave true"
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/usr/sbin pm-powersave false"

to /etc/udev/rules.d/

And the default Ubuntu powersave features will be applied when you switch from the battery to AC and back.

There is a problem that it is not triggered on boot. To fix it, add

udevadm trigger -s power_supply

to /etc/rc.local before exit0.

With Ubuntu 16.04 another problem is that Network Manager defaults to Power management off. When an interface is brought up, it overrides the pm-utils setting.

This can also be fixed by adding a file 02-powersave


[ "$1" = "wlan0" ] && [ "$2" = "up" ] && udevadm trigger -s power_supply

to /etc/NetworkManager/dispatcher.d.

Note: You need to replace wlan0 with your wireless interface that can be found in ifconfig.

| improve this answer | |
  • Good answer, however I need to do additional measures specific to sony vaio laptops, i.e. telling its special platform driver which thermal mode to use. This is not done by standard configuration of pm-utils, so custom script is needed anyway. – dilettant Mar 20 '16 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.