You are not logged in.

#1 2015-05-19 20:22:52

nonis
Member
Registered: 2009-05-20
Posts: 43

[re-solved] Why can't acpid run xbacklight? (I can run it myself)

EDIT: Solved. xbacklight uses xrandr, so it relies on an x server. Either run xbacklight inside X, or use another backlight tool that doesn't need X. I used baskerville's nice little backlight program.

___

I'm trying to get the brightness keys on my new laptop working. (Dell Inspiron 13 7000 series, model 7348 if it helps).

I've installed acpid and added the following case to the catchall /etc/acpi/handler.sh:

    video/brightness*)
        case "$2" in
            BRTUP)
                xbacklight +10
                logger 'Brightness up'
                ;;
            BRTDN)
                xbacklight -10
                logger 'Brightness down'
                ;;
            *)
                logger "ACPI action undefined: $2"
                ;;
        esac
        ;;

Now, when I press the brightness keys and run journalctl, I see the "Brightness up" or "Brightness down" messages but my brightness doesn't adjust. So I'm catching the correct messages, and it's running the commands, but for some reason xbacklight isn't doing anything.

If I run 'xbacklight +10' (or -10) from the command line as a user or root, I can adjust the backlight just fine. I even created a test shell script with just:

#!/bin/bash
xbacklight -10

and I can adjust the brightness with that as a normal user.

Any idea why the xbacklight command would be failing when called by acpid's handler.sh but not by hand? I don't think I'm missing anything from xbacklight's man/help files and the syntax looks fine in handler.sh

Thanks!

Last edited by nonis (2015-05-21 21:36:58)

Offline

#2 2015-05-19 20:32:20

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [re-solved] Why can't acpid run xbacklight? (I can run it myself)

Try calling the full path:

/usr/bin/xbacklight +10

Jin, Jîyan, Azadî

Offline

#3 2015-05-19 20:40:43

nonis
Member
Registered: 2009-05-20
Posts: 43

Re: [re-solved] Why can't acpid run xbacklight? (I can run it myself)

No luck. Same thing: works if I run it by hand or by a shell script but not when acpid runs it through handler.sh.

Offline

#4 2015-05-19 20:41:18

cris9288
Member
Registered: 2013-01-07
Posts: 348

Re: [re-solved] Why can't acpid run xbacklight? (I can run it myself)

It's just a bash script isn't it? Just try calling it from the command line (as the same user the process is running as) with the appropriate arguments to see what it says. I'm guessing that it's a system service (or not) running outside of the context of your user session so it doesn't have access to your $DISPLAY or $XAUTHORITY environment variables. You may need to set those before calling the xbacklight command.

Last edited by cris9288 (2015-05-19 20:41:52)

Offline

#5 2015-05-19 21:03:05

nonis
Member
Registered: 2009-05-20
Posts: 43

Re: [re-solved] Why can't acpid run xbacklight? (I can run it myself)

Thansk for the tip cris9288. I can run '/etc/acpi/handler.sh video/brightness BRTDN' and it turns down the brightness. Furthermore, I had the script log $XAUTHORITY and $DISPLAY and both are blank when being run by acpid.

As a test, I tried setting DISPLAY and XAUTHORITY to the same values they are for my user (:0 and /home/myuser/.Xauthority) in the shell script, but to no avail. passing '-display :0' to xbacklight in the script also doesn't do the trick.

Any advice on how to procede from here? Should I not be trying to run xbacklight outside of a user context? Do I have to write my own script to increment/decrement the backlight by percentages based on the files in /sys/class/backlight/... instead?

Offline

#6 2015-05-19 21:10:31

nonis
Member
Registered: 2009-05-20
Posts: 43

Re: [re-solved] Why can't acpid run xbacklight? (I can run it myself)

I think I'll just have sxhkd catch the brightness keys instead, since I'm already using it. I just viewed the source code of xbacklight and I guess it makes more sense now. I was thinking it was just a program to increment /sys/class/backlight... files by percentages, but it relies entirely on xrandr, so obviously it won't work outside of X.

Thanks!

Offline

#7 2015-05-19 22:16:04

cris9288
Member
Registered: 2013-01-07
Posts: 348

Re: [re-solved] Why can't acpid run xbacklight? (I can run it myself)

nonis wrote:

I think I'll just have sxhkd catch the brightness keys instead, since I'm already using it. I just viewed the source code of xbacklight and I guess it makes more sense now. I was thinking it was just a program to increment /sys/class/backlight... files by percentages, but it relies entirely on xrandr, so obviously it won't work outside of X.

Thanks!

I think this is a much better idea. You can always use xev to get the exact name of the keys you want to bind the commands to. acpid probably isn't the best tool for this particular task.

Offline

#8 2015-05-19 22:47:25

nonis
Member
Registered: 2009-05-20
Posts: 43

Re: [re-solved] Why can't acpid run xbacklight? (I can run it myself)

Agreed. I now have it working with sxhkd (yep... used xev to get key names). I originally wanted to use acpid because a) I only use sxhkd when I'm in bspwm, but sometimes I use openbox instead (sometimes I have to do work in netbeans and there are some issues with java not liking tiled WMs), and b) it'd be nice to have the backlight keys working outside of X.

Those aren't really high priority for me though, and if I find that I need to have acpid handle this I'll just go through /sys/class/backlight/.

Thanks again.

Offline

#9 2015-05-20 08:28:54

Alad
Wiki Admin/IRC Op
From: Bagelstan
Registered: 2014-05-04
Posts: 2,420
Website

Re: [re-solved] Why can't acpid run xbacklight? (I can run it myself)

https://wiki.archlinux.org/index.php/Ac … pid_socket

#!/bin/bash
nc -U /var/run/acpid.socket |
    while read event; do
	case "$event" in
	    video/brightness*BRTUP*)
		xbacklight +10
		;;
	esac
    done

That doesn't solve the outside X thing, but at least it works when input is blocked by e.g a screensaver (unlike sxhkd, I believe). You can try any of the following:

https://wiki.archlinux.org/index.php/Ba … _utilities

Last edited by Alad (2015-05-20 08:44:46)


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby

Offline

#10 2015-05-21 21:34:43

nonis
Member
Registered: 2009-05-20
Posts: 43

Re: [re-solved] Why can't acpid run xbacklight? (I can run it myself)

Just another quick update in case anyone has a similar concern in the future...

I found that someone made a tool already to adjust the backlight based on the sysfs brightness/maximum files (rather than based around xrandr like xbacklight). Turns out it's by baskerville, who also made bspwm and sxhkd. big_smile This works just fine outside X. It's in the AUR, too.

The relevant portion of my /etc/acpi/handler.sh now says:

    video/brightnessup)
        backlight +5%
        ;;
    video/brightnessdown)
        backlight -5%
        ;;

Offline

Board footer

Powered by FluxBB