You are not logged in.

#1 2014-10-13 17:36:04

Carl Karl
Member
Registered: 2013-06-12
Posts: 231

[solved] XFCE: bind custom script to backlight keys, including Notify?

Hello, the situation is as follows:
My (Toshiba Z30) backlight keys toggle the XFCE-brightness control popup, but they don't control the display brightness.
I found out why: they control /sys/class/backlight/toshiba/brightness instead of /sys/class/backlight/intel_backlight/brightness. I wasn't able to change that, although testing the kernel parameters acpi_backlight=vendor and acpi_osi='!Windows 2012'. That tip (bottom of the page) given in the arch wiki had no effect OR didn't even let me boot when I tried to adjust the BusID to the output of lspci...

So I got another solution, these selfmade scripts:

/usr/local/bin/darker
____________________________
#!/bin/bash
CURR=`cat /sys/class/backlight/intel_backlight/brightness`
MIN=3
NEW=$(($CURR-50))
if [ $NEW -lt 5 ]
  then
    NEW=5
fi
echo $NEW > /sys/class/backlight/intel_backlight/brightness 

and

/usr/local/bin/brighter
____________________________
#!/bin/bash
CURR=`cat /sys/class/backlight/intel_backlight/brightness`
MAX=`cat /sys/class/backlight/intel_backlight/max_brightness`
NEW=$(($CURR+50))
if [ $NEW -gt $MAX ]
  then
    NEW=$MAX
fi
echo $NEW > /sys/class/backlight/intel_backlight/brightness  

which work.

Assigning these scripts to keys also works with "sudo darker" / "sudo brighter" and adding them via visudo.

The only thing missing to make it perfect, is the combination:
Using the default brightness keys including the XFCE onscreen notification/popup binded to those scripts. (Just assigning to the brightness keys would make me lose the on screen notifiaction/popup...)

So how is that possible, has anyone an idea?

Last edited by Carl Karl (2014-10-14 15:21:14)

Offline

#2 2014-10-13 18:49:08

mar04
Member
From: Poland
Registered: 2010-02-08
Posts: 117

Re: [solved] XFCE: bind custom script to backlight keys, including Notify?

notify-send is one option.

Offline

#3 2014-10-13 23:31:26

Carl Karl
Member
Registered: 2013-06-12
Posts: 231

Re: [solved] XFCE: bind custom script to backlight keys, including Notify?

Thanks, that's quite good, except that multiple key-presses lead to multiple notification popups which is not sooo nice bad acceptable. (And as this is run by root, a sudo xfce4-notifyd-config is necessary to configure the notification.)

for reference:

/usr/local/bin/brighter
____________________________
#!/bin/bash
CURR=`cat /sys/class/backlight/intel_backlight/brightness`
MAX=`cat /sys/class/backlight/intel_backlight/max_brightness`
NEW=$(($CURR+20))
if [ $NEW -gt $MAX ]
  then
    NEW=$MAX
fi
echo $NEW > /sys/class/backlight/intel_backlight/brightness 
notify-send "Backlight $(($NEW*100/$MAX)) %"
/usr/local/bin/darker
__________________________
#!/bin/bash
CURR=`cat /sys/class/backlight/intel_backlight/brightness`
MIN=3
MAX=`cat /sys/class/backlight/intel_backlight/max_brightness`
NEW=$(($CURR-20))
if [ $NEW -lt 5 ]
  then
    NEW=5
fi
echo $NEW > /sys/class/backlight/intel_backlight/brightness 
notify-send "Backlight $(($NEW*100/$MAX)) %" 

So any idea how to avoid these multiple notifications? notify-send --help wasn't helpful for me.

Offline

#4 2014-10-13 23:41:24

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [solved] XFCE: bind custom script to backlight keys, including Notify?

A couple of pointers:

Have you tried lowering the timeout for the notifications?


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2014-10-13 23:48:41

Carl Karl
Member
Registered: 2013-06-12
Posts: 231

Re: [solved] XFCE: bind custom script to backlight keys, including Notify?

Thanks for that information  +

jasonwryan wrote:

Have you tried lowering the timeout for the notifications?

yes, the parameter --expire-time=(value in ms) seems to have no effect, at least if it is shorter than the one defined in xfce4-notifyd-config. But as these are my only notifications by root, setting by sudo xfce4-notifyd-config is also acceptable....   ...except of no shorter times than 1s can be set. So painting the screen full of notifications is still possible. ;-)

Offline

#6 2014-10-13 23:58:56

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [solved] XFCE: bind custom script to backlight keys, including Notify?

You don't need to use sudo: use xbacklight. See https://bitbucket.org/jasonwryan/shiv/s … brightness


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#7 2014-10-14 00:19:45

Carl Karl
Member
Registered: 2013-06-12
Posts: 231

Re: [solved] XFCE: bind custom script to backlight keys, including Notify?

nope. E.g. xbacklight -inc 40 has exactly no effect for me.

Offline

#8 2014-10-14 00:23:53

Carl Karl
Member
Registered: 2013-06-12
Posts: 231

Re: [solved] XFCE: bind custom script to backlight keys, including Notify?

OK, xbacklight works after defining:

/etc/X11/xorg.conf.d/30-backlight.conf
____________________________________________
Section "Device"
    Identifier             "Device0"
    Driver                 "intel"
    Option "Backlight"     "intel_backlight"
EndSection

Offline

#9 2014-10-14 15:20:20

Carl Karl
Member
Registered: 2013-06-12
Posts: 231

Re: [solved] XFCE: bind custom script to backlight keys, including Notify?

OK, I had time to include the tips, so now its:

/usr/local/bin/darker
________________________
#!/bin/bash
CURR=$(</sys/class/backlight/intel_backlight/brightness)
MIN=3
MAX=$(</sys/class/backlight/intel_backlight/max_brightness)
NEW=$((CURR-20))
if [[ $NEW -lt $MIN ]]
  then
    NEW=$MIN
fi
echo $NEW > /sys/class/backlight/intel_backlight/brightness 
notify-send "Backlight $((NEW*100/MAX)) %" 
/usr/local/bin
________________________
#!/bin/bash
CURR=$(</sys/class/backlight/intel_backlight/brightness)
MAX=$(</sys/class/backlight/intel_backlight/max_brightness)
NEW=$((CURR+20))
if [[ $NEW -gt $MAX ]]
  then
    NEW=$MAX
fi
echo $NEW > /sys/class/backlight/intel_backlight/brightness 
notify-send "Backlight $((NEW*100/MAX)) %"

Let's say it's good enough that way. It works and the multiple notifications look sort of funny... ;-)
(And I don't mind using sudo, because that way I have a way to set a shorter fadeout just for these notifiactions.)

Thanks again and solved.

Offline

Board footer

Powered by FluxBB