home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / acpid / examples / ac.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2006-07-20  |  1.1 KB  |  40 lines

  1. #!/bin/sh
  2. # /etc/acpid/ac.sh
  3. # Detect loss of AC power and regaining of AC power, and take action
  4. # appropriatly.
  5.  
  6. # On my laptop anyway, this script doesn't not get different parameters for
  7. # loss of power and regained power. So, I have to use a separate program to
  8. # tell what the adapter status is.
  9.  
  10. # This uses the spicctrl program for probing the sonypi device.
  11. BACKLIGHT=$(spicctrl -B)
  12.  
  13. if on_ac_power; then
  14.         # Now on AC power.
  15.  
  16.         # Tell longrun to go crazy.
  17.         longrun -f performance
  18.         longrun -s 0 100
  19.  
  20.         # Turn up the backlight unless it's up far enough.
  21.         if [ "$BACKLIGHT" -lt 108 ]; then
  22.                 spicctrl -b 108
  23.         fi
  24. else
  25.         # Now off AC power.
  26.  
  27.         # Tell longrun to be a miser.
  28.         longrun -f economy
  29.         longrun -s 0 50 # adjust to suite..
  30.  
  31.         # Don't allow the screen to be too bright, but don't turn the
  32.         # backlight _up_ on removal, and don't turn it all the way down, as
  33.         # that is unusable on my laptop in most conditions. Adjust to
  34.         # taste.
  35.         if [ "$BACKLIGHT" -gt 68 ]; then
  36.                 spicctrl -b 68
  37.         fi
  38. fi
  39.  
  40.