Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #!/bin/bash
  2. #
  3. # Macbook Air 6,2 power management script
  4. # copy to /etc/pm/power.d/99macbookair and chmod +x
  5. #
  6.  
  7. #
  8. # @param $1 idVendor
  9. # @param $2 idProduct
  10. # @param $3 type of powercontrol (on|auto)
  11. #
  12. set_usb_power_control()
  13. {
  14.     for dev in /sys/bus/usb/devices/* ; do
  15.         if [ -e $dev/idVendor -a \
  16.              -e $dev/idProduct -a \
  17.              -e $dev/power/control ] ; then
  18.             if [ x`cat $dev/idVendor` = x$1 -a \
  19.                  x`cat $dev/idProduct` = x$2 ] ; then
  20.                  echo Setting $dev to $3
  21.                  echo $3 > $dev/power/control
  22.             fi
  23.         fi
  24.     done
  25. }
  26.  
  27. case "$1" in
  28.     true) # powersaving on
  29.         # lower brightness (value from 1 to 15)
  30.         echo 600 > /sys/class/backlight/intel_backlight/brightness
  31.         # lower keyboard brightness value
  32.         echo 16 > /sys/class/leds/smc\:\:kbd_backlight/brightness
  33.  
  34.         # Autosuspend for USB device Apple Internal Keyboard / Trackpad [Apple Inc.]
  35.         # This is not handled by `tlp`
  36.         set_usb_power_control 05ac 0291 auto
  37.         ;;
  38.     false) # powersaving off
  39.         ;;
  40.     *)
  41.         exit 254
  42.         ;;
  43. esac
  44.  
  45. exit 0