home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / hal / scripts / hal-system-lcd-get-brightness next >
Encoding:
Text File  |  2006-08-30  |  2.2 KB  |  68 lines

  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2005 Richard Hughes <richard@hughsie.com>
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9.  
  10. # Check for environment variables
  11. if [ -z "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" ]; then
  12.     echo "Missing or empty environment variable(s)." >&2
  13.     echo "This script should be started by hald." >&2
  14.     exit 1
  15. fi
  16.  
  17. if [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "pmu" ]; then
  18.     value="`hal-system-power-pmu getlcd`"
  19.     if [ $? -ne 0 ]; then
  20.         echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
  21.         exit 1
  22.     fi
  23.     exit ${value}
  24. fi
  25.  
  26. # Check for file existance and that it's readable
  27. if [ ! -r "$HAL_PROP_LINUX_ACPI_PATH" ]; then
  28.     echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
  29.     echo "$1 not readable!" >&2
  30.     exit 1
  31. fi
  32.  
  33. if [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "toshiba" ]; then
  34.     # cat /proc/acpi/toshiba/lcd
  35.     #  brightness:              5
  36.     #  brightness_levels:       8
  37.     value="`cat $HAL_PROP_LINUX_ACPI_PATH | grep brightness: | awk '{print $2;}'`"
  38. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "asus" ]; then
  39.     # cat /proc/acpi/asus/brn
  40.     #  5
  41.     value="`cat $HAL_PROP_LINUX_ACPI_PATH`"
  42. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "panasonic" ]; then
  43.     # cat /proc/acpi/pcc/brightness
  44.     #  5
  45.     value="`cat $HAL_PROP_LINUX_ACPI_PATH`"
  46. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "ibm" ]; then
  47.     # cat /proc/acpi/ibm/brightness
  48.     #  level:          5
  49.     #  commands:       up, down
  50.     #  commands:       level <level> (<level> is 0-7)
  51.     value="`cat $HAL_PROP_LINUX_ACPI_PATH | grep level: | awk '{print $2;}'`"
  52. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "sony" ]; then
  53.     # cat /proc/acpi/sony/brightness
  54.     #  5
  55.     value="`cat $HAL_PROP_LINUX_ACPI_PATH`"
  56.     let "value = ${value} - 1"
  57. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "omnibook" ]; then
  58.     # cat /proc/omnibook/lcd
  59.     #  LCD brightness:  7
  60.     value="`cat $HAL_PROP_LINUX_ACPI_PATH | awk '{print $3;}'`"
  61. else
  62.     echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
  63.     echo "No ACPI method found" >&2
  64.     exit 1
  65.     fi
  66.  
  67. exit ${value}
  68.