home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / boot / i386 / rescue / usr / lib / hal / scripts / linux / hal-system-lcd-get-brightness-linux < prev    next >
Text File  |  2006-11-29  |  2KB  |  73 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. if [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "pmu" ]; then
  11.     value="`hal-system-power-pmu getlcd`"
  12.     if [ $? -ne 0 ]; then
  13.         echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
  14.         exit 1
  15.     fi
  16.     exit ${value}
  17. fi
  18.  
  19. # Check for file existance and that it's readable
  20. if [ ! -r $HAL_PROP_LINUX_ACPI_PATH ]; then
  21.     echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
  22.     echo "$1 not readable!" >&2
  23.     exit 1
  24. fi
  25.  
  26. if [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "toshiba" ]; then
  27.     # cat /proc/acpi/toshiba/lcd
  28.     #  brightness:              5
  29.     #  brightness_levels:       8
  30.     value="`cat $HAL_PROP_LINUX_ACPI_PATH | grep brightness: | awk '{print $2;}'`"
  31. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "asus" ]; then
  32.     # cat /proc/acpi/asus/brn
  33.     #  5
  34.     value="`cat $HAL_PROP_LINUX_ACPI_PATH`"
  35. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "panasonic" ]; then
  36.     # cat /proc/acpi/pcc/brightness
  37.     #  5
  38.     read value < $HAL_PROP_LINUX_ACPI_PATH
  39.     value=$[($value-51)/13]
  40. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "ibm" ]; then
  41.     # cat /proc/acpi/ibm/brightness
  42.     #  level:          5
  43.     #  commands:       up, down
  44.     #  commands:       level <level> (<level> is 0-7)
  45.     value="`cat $HAL_PROP_LINUX_ACPI_PATH | grep level: | awk '{print $2;}'`"
  46. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "sony" ]; then
  47.     # cat /proc/acpi/sony/brightness
  48.     #  5
  49.     value="`cat $HAL_PROP_LINUX_ACPI_PATH`"
  50.     let "value = ${value} - 1"
  51. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "omnibook" ]; then
  52.     # cat /proc/omnibook/lcd
  53.     #  LCD brightness:  7
  54.     value="`cat $HAL_PROP_LINUX_ACPI_PATH | awk '{print $3;}'`"
  55. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "sonypi" ]; then
  56.     # spicctrl -B
  57.     # 70
  58.     # 0..255
  59.     value="`/usr/sbin/spicctrl -B`"
  60.     RETVAL=$?
  61.     if [ $RETVAL != 0 ]; then
  62.         echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
  63.         exit 1;
  64.     fi
  65.     exit ${value}
  66. else
  67.     echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
  68.     echo "No ACPI method found" >&2
  69.     exit 1
  70. fi
  71.  
  72. exit ${value}
  73.