hal/tools hal-system-lcd-get-brightness, NONE, 1.1 hal-system-lcd-set-brightness, NONE, 1.1 Makefile.am, 1.20, 1.21

Richard Hughes hughsient at freedesktop.org
Sat Sep 3 08:54:20 PDT 2005


Update of /cvs/hal/hal/tools
In directory gabe:/tmp/cvs-serv26634

Modified Files:
	Makefile.am 
Added Files:
	hal-system-lcd-get-brightness hal-system-lcd-set-brightness 
Log Message:
Add new files needed for the SetBrightness and GetBrightness support.

--- NEW FILE: hal-system-lcd-get-brightness ---
#!/bin/sh
#
# Copyright (C) 2005 Richard Hughes <richard at hughsie.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# Check for file existance and that it's readable
if [ ! -r $HAL_PROP_LINUX_ACPI_PATH ]; then
	echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
	echo "$1 not readable!" >&2
	exit 1
fi

if [ "$HAL_PROP_LAPTOP_PANEL_ACPI_METHOD" == "toshiba" ]; then
	# cat /proc/acpi/toshiba/lcd
	#  brightness:              5
	#  brightness_levels:       8
	value="`cat $HAL_PROP_LINUX_ACPI_PATH | grep brightness: | awk '{print $2;}'`"
elif [ "$HAL_PROP_LAPTOP_PANEL_ACPI_METHOD" == "asus" ]; then
	# cat /proc/acpi/asus/brn
	#  5
	value="`cat $HAL_PROP_LINUX_ACPI_PATH`"
elif [ "$HAL_PROP_LAPTOP_PANEL_ACPI_METHOD" == "panasonic" ]; then
	# cat /proc/acpi/pcc/brightness
	#  5
	value="`cat $HAL_PROP_LINUX_ACPI_PATH`"
elif [ "$HAL_PROP_LAPTOP_PANEL_ACPI_METHOD" == "ibm" ]; then
	# cat /proc/acpi/ibm/brightness
	#  level:          5
	#  commands:       up, down
	#  commands:       level <level> (<level> is 0-7)
	value="`cat $HAL_PROP_LINUX_ACPI_PATH | grep level: | awk '{print $2;}'`"
elif [ "$HAL_PROP_LAPTOP_PANEL_ACPI_METHOD" == "sony" ]; then
	# cat /proc/acpi/sony/brightness
	#  5
	value="`cat $HAL_PROP_LINUX_ACPI_PATH`"
	let "value = ${value} - 1"
else
	echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
	echo "No acpi method script found" >&2
	exit 1
	fi

# Work out the percentage to return
let "percentage =  ( ( $value + 1 ) *  100 ) / $HAL_PROP_LAPTOP_PANEL_NUM_LEVELS"

exit ${percentage}

--- NEW FILE: hal-system-lcd-set-brightness ---
#!/bin/sh
#
# Copyright (C) 2005 Richard Hughes <richard at hughsie.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

read percentage

# Check for file existance and that it's writable
if [ ! -w $HAL_PROP_LINUX_ACPI_PATH ]; then
	echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
	echo "$1 not writable!" >&2
	exit 1
fi

# Work out the abs value
let "value = ( $percentage * $HAL_PROP_LAPTOP_PANEL_NUM_LEVELS ) / 100"

if [ "$HAL_PROP_LAPTOP_PANEL_ACPI_METHOD" == "toshiba" ]; then
	# echo "brightness: {0..x}" >/proc/acpi/toshiba/lcd
	echo "brightness: $value" > $HAL_PROP_LINUX_ACPI_PATH
elif [ "$HAL_PROP_LAPTOP_PANEL_ACPI_METHOD" == "asus" ]; then
	# echo {0..15} > /proc/acpi/asus/brn
	# http://www.taupro.com/wiki/ChemBook/LCDdisplayPowerConfiguration
	echo "$value" > $HAL_PROP_LINUX_ACPI_PATH
elif [ "$HAL_PROP_LAPTOP_PANEL_ACPI_METHOD" == "panasonic" ]; then
	# echo {0..15} > /proc/acpi/pcc/brightness
	# http://readlist.com/lists/vger.kernel.org/linux-kernel/7/36405.html
	echo "$value" > $HAL_PROP_LINUX_ACPI_PATH
elif [ "$HAL_PROP_LAPTOP_PANEL_ACPI_METHOD" == "ibm" ]; then
	# echo "level {0..7}" > /proc/acpi/ibm/brightness
	# http://ibm-acpi.sourceforge.net/README
	echo "level $value" > $HAL_PROP_LINUX_ACPI_PATH
elif [ "$HAL_PROP_LAPTOP_PANEL_ACPI_METHOD" == "sony" ]; then
	# echo "{1..8}" > /proc/acpi/sony/brightness
	# http://popies.net/sonypi/2.6-sony_acpi4.patch
	echo "$value" > $HAL_PROP_LINUX_ACPI_PATH
else
	echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
	echo "No acpi method script found" >&2
	exit 1
	fi

exit 0

Index: Makefile.am
===================================================================
RCS file: /cvs/hal/hal/tools/Makefile.am,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- Makefile.am	26 Aug 2005 20:11:18 -0000	1.20
+++ Makefile.am	3 Sep 2005 15:54:17 -0000	1.21
@@ -47,6 +47,8 @@
 	hal-luks-setup hal-luks-remove    \
 	hal-system-power-suspend          \
 	hal-system-power-hibernate        \
+	hal-system-lcd-get-brightness     \
+	hal-system-lcd-set-brightness     \
 	hal-system-power-set-power-save
 
 EXTRA_DIST=$(man_MANS) $(MAN_IN_FILES) gen-libgphoto-hal-fdi $(sbin_SCRIPTS)




More information about the hal-commit mailing list