You are not logged in.

#1 2014-07-13 01:13:21

olivarch
Member
Registered: 2013-01-26
Posts: 25

udev rules to turn off keyboard backlight on Asus UX32VD AFTER login

Hi,
I would like to turn off the keyboard backlight everytime my laptop starts.
.

I looked at :
https://wiki.archlinux.org/index.php/As … _Backlight

So I created a rule :

/etc/udev/rules.d/kbd_backlight.rules

SUBSYSTEM=="leds", ACTION=="add", KERNEL=="asus::kbd_backlight",DRIVERS=="asus-nb-wmi", ATTR{brightness}="0"

It works quite fine, after the boot the keyboard turns OFF.
But at GNOME login it goes ON again.

I found this :
https://wiki.archlinux.org/index.php/Ba … ht_service

and masked

systemctl mask systemd-backlight@leds:asus::kbd_backlight.service

No more success...

On grep later I masked this one :

systemctl mask sys-devices-platform-asus\x2dnb\x2dwmi-leds-asus::kbd_backlight.device 

Nothing new.

On more grep and I commented this :

/lib64/udev/rules.d/99-systemd.rules 
# SUBSYSTEM=="leds", KERNEL=="*kbd_backlight", TAG+="systemd", IMPORT{builtin}="path_id", ENV{SYSTEMD_WANTS}+="systemd-backlight@leds:$name.service"

I tried to understand a bit more with this, but without success:

https://wiki.archlinux.org/index.php/Ud … f_a_device

udevadm info -a -p /sys/class/leds/asus\:\:kbd_backlight

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight':
    KERNEL=="asus::kbd_backlight"
    SUBSYSTEM=="leds"
    DRIVER==""
    ATTR{brightness}=="0"
    ATTR{max_brightness}=="3"
    ATTR{trigger}=="[none] cpu0 cpu1 cpu2 cpu3 AC0-online rfkill0 phy0rx phy0tx phy0assoc phy0radio BAT0-charging-or-full BAT0-charging BAT0-full BAT0-charging-blink-full-solid rfkill2 rfkill3 "

  looking at parent device '/devices/platform/asus-nb-wmi':
    KERNELS=="asus-nb-wmi"
    SUBSYSTEMS=="platform"
    DRIVERS=="asus-nb-wmi"
    ATTRS{lid_resume}=="0"

  looking at parent device '/devices/platform':
    KERNELS=="platform"
    SUBSYSTEMS==""
    DRIVERS==""

Any idea ?
Thanks!

Offline

#2 2014-07-13 09:09:23

Rexilion
Member
Registered: 2013-12-23
Posts: 784

Re: udev rules to turn off keyboard backlight on Asus UX32VD AFTER login

Once gnome logs in, the systemd services should not be relevant unless:
- something is still starting in paralel, blocking the backlist service (but your mask command should have fixed that)
- gnome is doing something over dbus calling a service

Maybe try to disable some gnome services related to power management and keyboard handling?


fs/super.c : "Self-destruct in 5 seconds.  Have a nice day...\n",

Offline

#3 2014-07-13 18:39:02

olivarch
Member
Registered: 2013-01-26
Posts: 25

Re: udev rules to turn off keyboard backlight on Asus UX32VD AFTER login

Yes, it seems to come from Gnome and Dbus...
In particular, UPower.
It gives the interface to change the backlight keyboard
/usr/share/dbus-1/interfaces/org.freedesktop.UPower.KdbBacklight.xml

This blog shows some nice scripts to understand how to use it :
http://keramida.wordpress.com/2013/03/2 … -from-cli/

With systemctl I find again Upower:

● upower.service - Daemon for power management
   Loaded: loaded (/usr/lib/systemd/system/upower.service; disabled)
   Active: active (running) since Sun 2014-07-13 18:40:27 CEST; 1h 46min ago
     Docs: man:upowerd(8)
 Main PID: 447 (upowerd)
   CGroup: /system.slice/upower.service
           └─447 /usr/lib/upower/upowerd

Now I know that
- Upower can control the keyboard backlight
- Upower is loaded with systemd
- gnome-power-manager uses it

If gnome-power-manager is the main user of it:
- Why does it set the keyboard backlight to the max at start?
- How to change that ?
- How to know when it's done ? (journalctl ?)
- Shouldn't it set it the previous session value ?

If something else is setting the keyboard bakclight, who is the culprit ?

Last edited by olivarch (2014-07-13 18:57:35)

Offline

#4 2014-07-13 19:57:39

Rexilion
Member
Registered: 2013-12-23
Posts: 784

Re: udev rules to turn off keyboard backlight on Asus UX32VD AFTER login

Upower is nasty. I had it made disks spin up after a user logged in.

I think that upower uses some sort of reset mechanism to set everything to a known sane default.

My fear is that it's not possible to omit that.

You could block the dbus access. But dbus is still a bit of a black box to me.


fs/super.c : "Self-destruct in 5 seconds.  Have a nice day...\n",

Offline

#5 2014-07-14 15:03:50

olivarch
Member
Registered: 2013-01-26
Posts: 25

Re: udev rules to turn off keyboard backlight on Asus UX32VD AFTER login

This is driving me crazy...

At GRUB time the keyboard backlight goes on.

UDEV SCRIPT

/etc/udev/rules.d/kbd_backlight.rules

SUBSYSTEM=="leds", ACTION=="add", KERNEL=="asus::kbd_backlight",DRIVERS=="asus-nb-wmi", ATTR{brightness}="0"

=> turns it off later, more or less when the filesystem is loaded, but when gdm (login/passwd) starts it turns on again.

SYSTEMD SCRIPT
After some fight with systemd I could do a script (the tricky part was to start it at the good "level")

/etc/systemd/system/kbd_backlight_off.service

[Unit]
Description=Turns off the keyboard backlight
Requires=upower.service graphical.target network.target
After=upower.service graphical.target network.target

[Service]
Type=oneshot
RemainAfterExit=no
ExecStart= /usr/bin/dbus-send --type=method_call --system --dest=org.freedesktop.UPower /org/freedesktop/UPower/KbdBacklight org.freedesktop.UPower.KbdBacklight.SetBrightness "int32:0"

[Install]
WantedBy=graphical.target

=> useless, adds nothing to udev (standalone it has the same effect than the udev script)

DESKTOP AUTOSTART SCRIPT

.config/autostart/kbd_backlight_off.desktop

[Desktop Entry]
Type=Application
Exec=dbus-send --type=method_call --print-reply=literal --system --dest='org.freedesktop.UPower'  '/org/freedesktop/UPower/KbdBacklight' 'org.freedesktop.UPower.KbdBacklight.SetBrightness' "int32:0"
Hidden=false
X-GNOME-Autostart-enabled=true
Name[en_US]=kbd_backlight_off
Name=kbd_backlight_off
Comment[en_US]=kbd_backlight_off
Comment=kbd_backlight_off

=> it turns if off after the login, but when the background wallpaper is displayed it goes on again...

Shouldn't be so difficult to turn the keyboard backlight off, from the boot time... What am I missing ???

Offline

#6 2014-08-27 21:39:51

eirikep
Member
Registered: 2014-08-27
Posts: 2

Re: udev rules to turn off keyboard backlight on Asus UX32VD AFTER login

Hi, I have the same issues. Have tried tinkering with the desktop autostart script, and was thinking it could be fixed by adding a delay and set the keyboard backlight after it is set to maximum. Adding X-GNOME-Autostart-Delay=10 did nothing, though, and the backlight is still lowered on login only to be maximised again when the background wallpaper comes up.

Very frustrating!

Offline

#7 2014-09-19 07:07:16

zanardi84
Member
Registered: 2011-08-23
Posts: 10

Re: udev rules to turn off keyboard backlight on Asus UX32VD AFTER login

I have the same issue on my Asus n550jv laptop.

I managed to turn off the keyboard on Ubutnu 14.04 using this script

 #!/bin/bash
/usr/bin/dbus-send --type=method_call --system --dest=org.freedesktop.UPower /org/freedesktop/UPower/KbdBacklight org.freedesktop.UPower.KbdBacklight.SetBrightness "int32:0"

givind it 775 permissions, but the brightness is restored to the max value when the screen is turned on after its power management rule (turning off after X minutes).

I know that xfce 4.10 power manager can't manage the keyboard backlight:  two useful scripts are required and they work flawlessy (no OSD, but it's not a problem imho) restoring the right value saved before rebooting. From this statement the idea is to disable the gnome management of it, but I didn't found any setting in dconf editor. So, the question is: how to disable the gnome keyboard lights management?

Last edited by zanardi84 (2014-09-19 07:07:38)

Offline

Board footer

Powered by FluxBB