You are not logged in.
Hi guys,
I just want to set the brightness depending on whether my laptop is connected to AC or not. Therefore I tried the following in handler.sh
#!/bin/sh
# Default acpi script that takes an entry for all actions
# NOTE: This is a 2.6-centric script.  If you use 2.4.x, you'll have to
#       modify it to not use /sys
minspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq`
maxspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`
setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"
set $*
case "$1" in
    button/power)
        #echo "PowerButton pressed!">/dev/tty5
        case "$2" in
            PBTN|PWRF)  logger "PowerButton pressed: $2" ;;
            *)          logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/sleep)
        case "$2" in
            SLPB)   echo -n mem >/sys/power/state ;;
            *)      logger "ACPI action undefined: $2" ;;
        esac
        ;;
    ac_adapter)
        case "$2" in
            AC|ACAD|ADP0|AC0)
                case "$4" in
                    00000080)
                        echo -n $minspeed >$setspeed
			xbacklight -set 0
                        #/etc/laptop-mode/laptop-mode start
                    ;;
                    00000000)
                        echo -n $maxspeed >$setspeed
			xbacklight -set 0
                        #/etc/laptop-mode/laptop-mode stop
                    ;;
                esac
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    battery)
        case "$2" in
            BAT0)
                case "$4" in
                    00000081)   #echo "offline" >/dev/tty5
				xbacklight -set 0
                    ;;
                    00000001)   #echo "online"  >/dev/tty5
				xbacklight -set 0
                    ;;
                esac
                ;;
            CPU0)	
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/lid)
        #echo "LID switched!">/dev/tty5
        ;;
    *)
        logger "ACPI group/action undefined: $1 / $2"
        ;;
esacYou can see that for testing purposes I added xbacklight on the AC as well as BAT handler. I got the states from acpi_listen.
# Disconnecting AC
ac_adapter AC0 00000080 00000000
hotkey ATKD 00000057 0000000d
processor CPU0 00000081 00000000
processor CPU1 00000081 00000000
battery BAT0 00000080 00000001
battery BAT0 00000081 00000001
ac_adapter AC0 00000080 00000000
# Connecting AC again
ac_adapter AC0 00000080 00000001
hotkey ATKD 00000058 0000000d
processor CPU0 00000081 00000000
processor CPU1 00000081 00000000
battery BAT0 00000080 00000001
battery BAT0 00000081 00000001
ac_adapter AC0 00000080 00000001Last edited by orschiro (2011-09-14 12:13:42)
Offline
Anyone?
It would be much easier to help if you'd actually ask a question ;-)
Does the xbacklight work at all? ...from console
Does it work in root context?
Try to disable X access control (xhost +local:)
Offline
Hi laloch,
Sorry about that. I tried to set the backlight through xbacklight -set 0 to zero when the Laptop is using battery. Therefore I defined xbacklight -set 0 at every possible position within handler.sh but none of that acpi events works. That's why I posted you the output of acpi_listen.
And yes, xbacklight works properly. So it is just a problem with acpid's handler.sh
Does this make clearer what I want?
Regards
Last edited by orschiro (2011-09-11 21:43:44)
Offline
If you replace the xbacklight by
logger "some message", does the message appear in /var/log/messages? If it doesn't, you probably need to add acpid to DAEMONS array in /etc/rc.conf
Offline
The xbacklight clearly needs an X server access...
[laloch@uriel ~]$ su
Password: 
[root@uriel laloch]# xbacklight 
No protocol specified
Cannot open display ":0"Edit:
Do you have something in /sys/class/backlight directory?
Last edited by laloch (2011-09-11 22:18:11)
Offline
I changed my handler.sh to the following:
#!/bin/sh
# Default acpi script that takes an entry for all actions
# NOTE: This is a 2.6-centric script.  If you use 2.4.x, you'll have to
#       modify it to not use /sys
minspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq`
maxspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`
setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"
set $*
case "$1" in
    button/power)
        #echo "PowerButton pressed!">/dev/tty5
        case "$2" in
            PBTN|PWRF)  logger "PowerButton pressed: $2" ;;
            *)          logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/sleep)
        case "$2" in
            SLPB)   echo -n mem >/sys/power/state ;;
            *)      logger "ACPI action undefined: $2" ;;
        esac
        ;;
    ac_adapter)
        case "$2" in
            AC|ACAD|ADP0|AC0)
                case "$4" in
                    00000080)
                        #echo -n $minspeed >$setspeed
			DISPLAY=:0.0 xbacklight -set 0
                        #/etc/laptop-mode/laptop-mode start
                    ;;
                    00000000)
                        #echo -n $maxspeed >$setspeed
			DISPLAY=:0.0 xbacklight -set 0
                        #/etc/laptop-mode/laptop-mode stop
                    ;;
                esac
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    battery)
        case "$2" in
            BAT0)
                case "$4" in
                    00000081)   #echo "offline" >/dev/tty5
				DISPLAY=:0.0 xbacklight -set 0
                    ;;
                    00000001)   #echo "online"  >/dev/tty5
				DISPLAY=:0.0 xbacklight -set 0
				logger "xbacklight issue"
                    ;;
                esac
                ;;
            CPU0)	
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/lid)
        #echo "LID switched!">/dev/tty5
	/usr/sbin/pm-suspend 
	DISPLAY=:0.0 su -c - robert /usr/bin/slimlock
        ;;
    *)
        logger "ACPI group/action undefined: $1 / $2"
        ;;
esacReceiving the following message in var/log/messages:
Sep 12 10:24:51 localhost logger: ACPI group/action undefined: processor / CPU0
Sep 12 10:24:51 localhost logger: ACPI group/action undefined: processor / CPU1
Sep 12 10:24:51 localhost logger: xbacklight issue
Sep 12 10:24:51 localhost logger: xbacklight issueUnfortunately xbacklight is still not working. Any other ideas?
Last edited by orschiro (2011-09-11 22:26:48)
Offline
Run xhost +local:
The xbacklight should work then, but I don't see this as "proper" solution. /sys/class/backlight would be better.
Offline
Offline