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-set-brightness-linux < prev    next >
Text File  |  2006-11-29  |  2KB  |  67 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.     hal-system-power-pmu setlcd $value
  12.     if [ $? -ne 0 ]; then
  13.         echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
  14.         exit 1
  15.     fi
  16.     exit 0
  17. fi
  18.  
  19. # Check for file existance and that it's writable
  20. if [ ! -w $HAL_PROP_LINUX_ACPI_PATH ]; then
  21.     echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
  22.     echo "$1 not writable!" >&2
  23.     exit 1
  24. fi
  25.  
  26. if [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "toshiba" ]; then
  27.     # echo "brightness: {0..x}" >/proc/acpi/toshiba/lcd
  28.     echo "brightness: $value" > $HAL_PROP_LINUX_ACPI_PATH
  29. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "asus" ]; then
  30.     # echo {0..15} > /proc/acpi/asus/brn
  31.     # http://www.taupro.com/wiki/ChemBook/LCDdisplayPowerConfiguration
  32.     echo "$value" > $HAL_PROP_LINUX_ACPI_PATH
  33. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "panasonic" ]; then
  34.     # echo {0..15} > /proc/acpi/pcc/brightness
  35.     # http://readlist.com/lists/vger.kernel.org/linux-kernel/7/36405.html
  36.     echo "$[($value*136)/10+51]" > $HAL_PROP_LINUX_ACPI_PATH
  37. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "ibm" ]; then
  38.     # echo "level {0..7}" > /proc/acpi/ibm/brightness
  39.     # http://ibm-acpi.sourceforge.net/README
  40.     echo "level $value" > $HAL_PROP_LINUX_ACPI_PATH
  41. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "sony" ]; then
  42.     # echo "{1..8}" > /proc/acpi/sony/brightness
  43.     # http://popies.net/sonypi/2.6-sony_acpi4.patch
  44.     echo "$((value + 1))" > $HAL_PROP_LINUX_ACPI_PATH
  45. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "omnibook" ]; then
  46.     # echo "{0..7}" > /proc/omnibook/lcd
  47.     # http://bugzilla.gnome.org/show_bug.cgi?id=331458
  48.     echo "$value" > $HAL_PROP_LINUX_ACPI_PATH
  49. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "sonypi" ]; then
  50.     # spicctrl -B
  51.     # 70
  52.     # 0..255
  53.     value="`/usr/sbin/spicctrl -B`"
  54.     RETVAL=$?
  55.     if [ $RETVAL != 0 ]; then
  56.         echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
  57.         exit 1;
  58.     fi
  59.     exit ${value}
  60. else
  61.     echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
  62.     echo "No ACPI method found" >&2
  63.     exit 1
  64. fi
  65.  
  66. exit 0
  67.