Ubuntu 15.04, pm-utils do not look into /etc/pm/power.d/ anymore, what instead?
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)?
Solution 1:
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:
/etc/udev/rules.d/powersave.rules 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:
/etc/udev/rules.d/99-laptopac.rules
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"
/usr/local/bin/sony-thermal.sh
#!/bin/sh 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. EOF } 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 performance) printf "Setting SONY thermal control to performace mode." thermal_control=performance ;; silent) printf "Setting SONY thermal control to silent mode." thermal_control=silent ;; *) printf "Setting SONY thermal control to balanced mode." thermal_control=balanced ;; esac 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 ;; esac 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.
Solution 2:
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
#!/bin/sh
[ "$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
.