Permalink
Browse files

Update h3consumption for new Wi-Fi PM settings

  • Loading branch information...
1 parent 12094ea commit f2cb36b4e7de99d816fb4cb5b5a968e9d28a691f @zador-blood-stained zador-blood-stained committed Jan 6, 2017
Showing with 34 additions and 7 deletions.
  1. +34 −7 scripts/h3consumption
View
@@ -240,15 +240,42 @@ ChangeSettings() {
"")
: ;;
on)
- chmod 644 /etc/NetworkManager/dispatcher.d/99disable-power-management
- sed 's/power\ off\ /power on /' </etc/NetworkManager/dispatcher.d/99disable-power-management \
- > /etc/NetworkManager/dispatcher.d/99enable-power-management
- chmod 755 /etc/NetworkManager/dispatcher.d/99enable-power-management
+ rm -f /etc/NetworkManager/dispatcher.d/99enable-power-management \
+ /etc/NetworkManager/dispatcher.d/99disable-power-management \
+ /etc/NetworkManager/conf.d/zz-override-wifi-powersave-off.conf
+
;;
off)
- chmod 755 /etc/NetworkManager/dispatcher.d/99disable-power-management
- [[ -f /etc/NetworkManager/dispatcher.d/99enable-power-management ]] &&
- chmod 644 /etc/NetworkManager/dispatcher.d/99enable-power-management
+ rm -f /etc/NetworkManager/dispatcher.d/99enable-power-management \
+ /etc/NetworkManager/dispatcher.d/99disable-power-management \
+ /etc/NetworkManager/conf.d/zz-override-wifi-powersave-off.conf
+
+ echo "Note: This action applies only to NetworkManager based connections"
+
+ case "$(lsb_release -sc)" in
+ jessie)
+ mkdir -p /etc/NetworkManager/dispatcher.d/
+ cat <<-'EOF' > /etc/NetworkManager/dispatcher.d/99disable-power-management
+ #!/bin/sh
+ case "$2" in
+ up) /sbin/iwconfig $1 power off || true ;;
+ down) /sbin/iwconfig $1 power on || true ;;
+ esac
+ EOF
+ chmod 755 /etc/NetworkManager/dispatcher.d/99disable-power-management
+ ;;
+ xenial)
+ mkdir -p /etc/NetworkManager/conf.d/
+ cat <<-EOF > /etc/NetworkManager/conf.d/zz-override-wifi-powersave-off.conf
+ [connection]
+ wifi.powersave = 2
+ EOF
+ ;;
+ *)
+ echo "This action is supported only in Jessie and Xenial based releases. Exiting" >&2
+ exit 1
+ ;;
+ esac
;;
*)
echo "Parameter error: -w requires either on or off. Exiting" >&2

0 comments on commit f2cb36b

Please sign in to comment.