You are not logged in.

#1 2020-05-20 04:01:05

kr37
Member
Registered: 2018-03-17
Posts: 11

How to bind xbacklight to brightness keys?

Hi all, thanks for all the wonderful posts. I haven't found anything that quite hits this question.

On BL Helium (except upgraded to Buster) on a Lenovo T410, things are working great, just like normal. `xbacklight` works very well, with fine control. But whatever is bound to the brightness keys is much courser, with a big jump from not-so-bright to no-backlight-at-all. Is there a way to bind xbacklight to the brightness keys on the keyboard? Where is it set what happens when the brightness keys are pressed?

On this machine, the brightness keys are not actual function keys, but FN+Home and FN+End.

sudo showkey

reports them as 225 and 224.

I know the xfce4 power icon in the tray has a nice brightness slider, which has fine-grain control, but just wondering if I could get the brightness keys to work nicely. (This is definitely a first-world problem.)


What is Lamrim?

Offline

#2 2020-05-20 07:29:21

Naik
Member
From: Lipsia
Registered: 2015-10-03
Posts: 219

Re: How to bind xbacklight to brightness keys?

Hey there,

You may have a look at the Lithium-dev configs or a little patience...
I never thought about his and for me (FN-F9 and FN-F10) it works just out of the box.

Diving deeper into the problem it shows that even  xfpm-power-backlight-helper may be of little to no help here since it is not able to set increase/decrease values which would need an extra script for retrieving the current value and the max-value and creating another one to pass to the helper...

I am absolutly sure that there is (must be) a simple solution to this but  as far as I can tell there is no way to define key chains starting with "Fn" via ~/.config/opnebox/rc.xml BUT the key number can be given as Hexadecimal according to this guide here

Based on this and that writings you may also go with xmodmap or you may have a look at OBKey

I hope you will find a solution soon or have a good time reading until SO drops in who knows what they are talking about.

EDIT: They are the same numbers to me according to sudo showkey, so chances are they are recognised as XF86MonBrightnessUp and XF86MonBrightnessDown by your system allready which may be used in ~/.config/opnebox/rc.xml too..

naik --greetz

Last edited by Naik (2020-05-20 07:36:55)


"Kaum macht [Mensch]* es richtig, funktioniert es sofort!"
BL-Kitchen on GitHub

Offline

#3 2020-05-20 09:36:34

PackRat
jgmenu user Numero Uno
Registered: 2015-10-02
Posts: 1,203

Re: How to bind xbacklight to brightness keys?

Check your ~/.config/openbox/rc.xml file to see if there are already key bindings for xbaclight. The keys are usually named what Naik posted. If there are, you can change the values for increase/decrease to something more useful.

If xfce4-power-manager has control of the brightness keys, then there may be an option to control the amount of increase/decrease of the keypress from it's configuration.


You must unlearn what you have learned.
    -- yoda

Offline

#4 2020-05-21 04:46:15

kr37
Member
Registered: 2018-03-17
Posts: 11

Re: How to bind xbacklight to brightness keys?

Thank you for the tips.
rc.xml has no references to xbacklight, XF86MonBrightnessUp or XF86MonBrightnessDown.

xev gives the following, in which XF86WakeUp seems to be the Fn key. Otherwise, it's not very intelligible to me. The serial 68, 69 etc goes up and down with the brightness.

KeyPress event, serial 68, synthetic NO, window 0x4c00001,
    root 0xc8, subw 0x0, time 249998223, (980,500), root:(983,559),
    state 0x0, keycode 151 (keysym 0x1008ff2b, XF86WakeUp), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 69, synthetic NO, window 0x4c00001,
    root 0xc8, subw 0x0, time 249998747, (980,500), root:(983,559),
    state 0x0, keycode 151 (keysym 0x1008ff2b, XF86WakeUp), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

MappingNotify event, serial 69, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

FocusOut event, serial 69, synthetic NO, window 0x4c00001,
    mode NotifyGrab, detail NotifyAncestor

FocusIn event, serial 69, synthetic NO, window 0x4c00001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 69, synthetic NO, window 0x0,
    keys:  1   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

RRNotify event, serial 70, synthetic NO, window 0x4c00001,
    subtype XRROutputPropertyChangeNotifyEvent
    output LVDS1, property Backlight, timestamp 250000993, state NewValue

I tried putting this in rc.xml, but no help (I figured if htop showed up that would be pretty clear that we've caught the event).

    <keybind key="0xE1">
      <action name="BrightnessUp">
        <command>x-terminal-emulator -T 'htop task manager' -e htop</command>
      </action>
    </keybind>

Ah, I just started looking at your 'this' and 'that'. They seem quite relevant. But no time at the moment.


What is Lamrim?

Offline

#5 2020-05-21 05:08:22

damo
....moderator....
Registered: 2015-08-20
Posts: 5,978

Re: How to bind xbacklight to brightness keys?

Try

<keybind key="XF86WakeUp">
<action name="Execute">
...

Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#6 2020-05-21 05:44:49

kr37
Member
Registered: 2018-03-17
Posts: 11

Re: How to bind xbacklight to brightness keys?

Thank you, Damo,

    <keybind key="XF86WakeUp">
      <action name="Execute">
        <command>xbacklight -dec 1</command>
      </action>
    </keybind>

This makes the Fn key by itself into brightness down, which isn't a bad solution. It still works that Fn-Home is coarse brightness up, and Fn-End is course brightness down. But now I have a fine brightness down as well.


What is Lamrim?

Offline

#7 2020-05-21 13:38:33

PackRat
jgmenu user Numero Uno
Registered: 2015-10-02
Posts: 1,203

Re: How to bind xbacklight to brightness keys?

XF86WakeUp is the output for both Fn+Home and Fn+End in xev?
Also the "keysym 0x1008ff2b" is the same; that doesn't look right. I would think those would show as different keys.

In the short term, you can set up some other keys to control the brightness, i.e ALT+F5.


You must unlearn what you have learned.
    -- yoda

Offline

#8 2020-05-21 15:36:37

kr37
Member
Registered: 2018-03-17
Posts: 11

Re: How to bind xbacklight to brightness keys?

Thank you, Packrat,

No, in the xev output above, the first two "paragraphs" are just the Fn key by itself. The later ones that don't seem to give a clear key code are the Fn-Home and Fn-End.

I took you suggestion and bound to Fn-F7 and Fn-F8 which give XF86Display and XF86TouchpadToggle. That works great.

For lower brightnesses, the new keys are good. For higher brightnesses, they're a bit slow, so I can use the original ones.  Maybe someday I'll work out a log script for it all.

Thanks for all the help!


What is Lamrim?

Offline

#9 2020-05-21 16:27:42

PackRat
jgmenu user Numero Uno
Registered: 2015-10-02
Posts: 1,203

Re: How to bind xbacklight to brightness keys?

The later ones that don't seem to give a clear key code are the Fn-Home and Fn-End.

That's because something has control over those keys to change the brightness like you stated in your original post. Works like that for most assigned function keys; if I press the XF86HomePage key, it doesn't show in xev, it just launches Firefox.


You must unlearn what you have learned.
    -- yoda

Offline

#10 2020-05-21 17:15:47

damo
....moderator....
Registered: 2015-08-20
Posts: 5,978

Re: How to bind xbacklight to brightness keys?

Brightness script on my (Helium) system:
(adjust for xbindkeys or bl-rc.xml on Lithium)
rc.xml

    <!-- SCREEN BRIGHTNESS -->
    <keybind key="C-F9">
      <action name="Execute">
        <command>brightness plus</command>
      </action>
    </keybind>
    <keybind key="C-F8">
      <action name="Execute">
        <command>brightness minus</command>
      </action>
    </keybind>

brightness script

#!/bin/bash
##
## brightness

BRIGHTNESS="$HOME/.config/mon-brightness.rc"

if [[ -f $BRIGHTNESS ]];then
    VAL=$(<$BRIGHTNESS)
else
    VAL=1.0
    echo $VAL > $BRIGHTNESS
fi

if [[ $1 = plus ]];then
    VAL=$(awk -v "VAL=$VAL" 'BEGIN { print VAL + 0.1 }')
elif [[ $1 = minus ]];then
    VAL=$(awk -v "VAL=$VAL" 'BEGIN { print VAL - 0.1 }')
else
    notify-send -t 3000 "Use 'brightness plus/minus'"
    exit 1
fi

echo $VAL > $BRIGHTNESS

# edit to the monitor identifier in use
xrandr --output DVI-D-0 --brightness $VAL --output HDMI-0 --brightness $VAL

The current value is stored in $HOME/.config/mon-brightness.rc


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#11 2020-05-22 03:58:46

kr37
Member
Registered: 2018-03-17
Posts: 11

Re: How to bind xbacklight to brightness keys?

Thank you, Damo,

That script seems like it adjusts the contrast more than the backlight. Handy to be able to control that as well. (And pretty trippy when it gets into negative numbers!)

Thanks so much!


What is Lamrim?

Offline

#12 2020-05-22 06:43:47

ohnonot
...again
Registered: 2015-09-29
Posts: 4,521
Website

Re: How to bind xbacklight to brightness keys?

kr37 wrote:

in the xev output above, the first two "paragraphs" are just the Fn key by itself.

Strange, on both my machines the Fn key by itself does not register at all for xev.


BL quote proposals to this thread please.
how to ask smart questions | my repos / my repos | my blog
---
Thank you for posting direct image links!

Offline

Board footer

Powered by FluxBB