keyboard backlight doesn't work [Solved]

Issues Related to Hardware (Sound, Video, Printers, Scanners, Webcams, Touchpads, Keyboards, Sensors, Drives, GRUB, etc.)

Moderator: Moderators

fjkhf
Simple Hen
Posts: 97
Joined: Tue Jun 26, 2012 13:41

keyboard backlight doesn't work [Solved]

Post by fjkhf » Mon Oct 21, 2013 18:45

Hello , I am using Sabayon KDE and I bought 'coolermaster devastator' keyboard which has backlight.
It supposes to work by pressing Scr key ,but it doesn't.

I went to System Settings->Input Devices ->Keyboard and it has an option
use keyboard LED to show alternative layout
and the backlight turns on and off when I change the layout!
Can I do sth to enable it by pressing a key?


Thanks!

User avatar
Fitzcarraldo
Sagely Hen
Posts: 8094
Joined: Sat Mar 10, 2007 5:40
Location: United Kingdom
Contact:

Re: keyboard backlight doesn't work

Post by Fitzcarraldo » Mon Oct 21, 2013 21:31

I'm not sure, but you could try creating a file /etc/X11/xorg.conf.d/00-keyboard.conf containing the following:

Code: Select all

Section "InputClass"
    Identifier "keyboard"
    MatchIsKeyboard "yes"
    Option "XkbLayout" "gb"
    Option "XkbVariant" ""
    Option "XkbOptions" "grp_led:num"
EndSection
That would presumably toggle the backlight when you press the Num Lock key, which is not ideal but better than the other key options (Caps Lock and Scroll Lock). The possible options that I know of regarding a keyboard LED are:

Code: Select all

grp_led              Use keyboard LED to show alternative layout
grp_led:num          Num Lock
grp_led:caps         Caps Lock
grp_led:scroll       Scroll Lock
You didn't indicate which language layout your keyboard uses. If your keyboard has a non-British layout then change the "gb" to the required layout code. For example, if your keyboard has a US layout, replace "gb" with "us".

If you already have a keyboard configuration file in the directory /etc/X11/xorg.conf.d/ then edit that instead of creating a new file. And if you have the file /etc/X11/xorg.conf with a section for the keyboard in it then try adding the option to that section instead.

All the possible XkbModels, XkbLayouts, XkbVariants and XkbOptions are listed in the text file /usr/share/X11/xkb/rules/xorg.lst.

fjkhf
Simple Hen
Posts: 97
Joined: Tue Jun 26, 2012 13:41

Re: keyboard backlight doesn't work

Post by fjkhf » Mon Oct 21, 2013 22:07

Hello,

unfortunately it doesn't work..

The file 00-keyboard.conf exists and also the /etc/X11/xorg.conf exists.

I tried to add the Section "InputClass" ... to /etc/X11/xorg.conf but still the same..

The options
grp_led Use keyboard LED to show alternative layout
grp_led:num Num Lock
grp_led:caps Caps Lock
grp_led:scroll Scroll Lock
you gave me exist also in the system setttings as I wrote above but they refer only to alternative layout.You must choose first the
Use keyboard LED to show alternative layout
and then the button (num,scroll,caps) in order to do it.

Any other ideas?
Thank you

User avatar
Fitzcarraldo
Sagely Hen
Posts: 8094
Joined: Sat Mar 10, 2007 5:40
Location: United Kingdom
Contact:

Re: keyboard backlight doesn't work

Post by Fitzcarraldo » Tue Oct 22, 2013 13:26

Open a Konsole window, log in as root user, and see whether you have a keyboard backlight file in one of the sub-directories of the /sys/devices/ directory. For example, DuckDuckGo is telling me that the keyboard backlight on one model of Sony laptop can be switched on by issuing the command:

Code: Select all

echo 1 > /sys/devices/platform/sony-laptop/kbd_backlight
and off by issuing the command:

Code: Select all

echo 0 > /sys/devices/platform/sony-laptop/kbd_backlight
If you can find the relevant file (it might or might not be named kbd_backlight) in the Linux kernel system file system then the applicable commands could be tied to keyboard shortcuts in KDE.

fjkhf
Simple Hen
Posts: 97
Joined: Tue Jun 26, 2012 13:41

Re: keyboard backlight doesn't work

Post by fjkhf » Tue Oct 22, 2013 13:55

Unfortunately I don't find any backlight file in the /sys/devices/platform folder..

User avatar
Fitzcarraldo
Sagely Hen
Posts: 8094
Joined: Sat Mar 10, 2007 5:40
Location: United Kingdom
Contact:

Re: keyboard backlight doesn't work

Post by Fitzcarraldo » Tue Oct 22, 2013 13:58

Yes, but have you looked in the other sub-directories in /sys/devices/? I.e. what other sub-directories are there in /sys/devices/?

Code: Select all

# ls -la /sys/devices

User avatar
Fitzcarraldo
Sagely Hen
Posts: 8094
Joined: Sat Mar 10, 2007 5:40
Location: United Kingdom
Contact:

Re: keyboard backlight doesn't work

Post by Fitzcarraldo » Tue Oct 22, 2013 15:27

Or even other sub-directories in /sys/ (might be /sys/class/leds/ for example).

Additionally, I see that the X Windows command xset also has an option for LEDs. check the man page:

Code: Select all

man xset
There are various options for LEDs:

Code: Select all

[led {on|off}]

Code: Select all

[-led [integer]] [+led [integer]]

Code: Select all

led      The  led  option controls the keyboard LEDs.  This controls the
         turning on or off of one or all of the  LEDs.   It  accepts  an
         optional  integer, a preceding dash(-) or an 'on/off' flag.  If
         no parameter or the 'on' flag is given, all LEDs are turned on.
         If  a  preceding  dash or the flag 'off' is given, all LEDs are
         turned off.  If a value between 1 and 32  is  given,  that  LED
         will  be  turned on or off depending on the existence of a pre-
         ceding dash.  A common LED  which  can  be  controlled  is  the
         ``Caps  Lock''  LED.   ``xset  led  3''  would  turn led #3 on.
         ``xset -led 3'' would turn it off.  The particular  LED  values
         may refer to different LEDs on different hardware.

fjkhf
Simple Hen
Posts: 97
Joined: Tue Jun 26, 2012 13:41

Re: keyboard backlight doesn't work

Post by fjkhf » Tue Oct 22, 2013 16:57

If I type

Code: Select all

xset led named "Scroll Lock"
the leds are turned on!But ,I can't turn them off.
I must type

Code: Select all

xset led named "Scroll Lock" 
to turn them off.


Is there a way to accomplish that with a key?(scroll lock)

The

Code: Select all

ls -la /sys/devices
gives:
.
... ..
...breakpoint
...cpu
...LNXSYSTM:00
...pci0000:00
...platform
...pnp0
... rapidio
...software
... system
... virtual
Also , there are various "led" files in vatious subfolders inside sys.

Thanks for helping.

User avatar
Fitzcarraldo
Sagely Hen
Posts: 8094
Joined: Sat Mar 10, 2007 5:40
Location: United Kingdom
Contact:

Re: keyboard backlight doesn't work

Post by Fitzcarraldo » Tue Oct 22, 2013 17:43

fjkhf wrote:If I type

Code: Select all

xset led named "Scroll Lock"
the leds are turned on!But ,I can't turn them off.
I must type

Code: Select all

xset led named "Scroll Lock" 
to turn them off.
I assume you forgot to quote the minus sign in the second command (to turn off the LEDs)?:

Code: Select all

xset -led named "Scroll Lock"
Is there a way to accomplish that with a key?(scroll lock)
Yes, there is. Several ways, actually. For example, you could create a simple Bash script along the lines shown below to toggle the backlight on/off, and set up a keyboard shortcut to launch it. In KDE you can set up keyboard shortcuts via e.g. 'System Settings' > 'Shortcuts and Gestures' > 'Custom Shortcuts'.

Code: Select all

#!/bin/bash
if [ -f /home/fjkhf/keyboard_led ]; then
   xset -led named "Scroll Lock" && rm /home/fjkhf/keyboard_led
else
   xset led named "Scroll Lock" && touch /home/fjkhf/keyboard_led
fi
If, for example, you created a script named /home/fjkhf/toggle_keyboard_backlight.sh then you would also need to enter the following command in order to make it executable:

Code: Select all

chmod +x /home/fjkhf/toggle_keyboard_backlight.sh

fjkhf
Simple Hen
Posts: 97
Joined: Tue Jun 26, 2012 13:41

Re: keyboard backlight doesn't work

Post by fjkhf » Tue Oct 22, 2013 18:24

I have a problem , I can't bind scroll lock to script.

I created the script you gave me , it works if I execute it (turns on ,execute again and turns off).

I tried to go to Create custom shortcuts but I am not sure what is the right way.
I chose Konqueror Gestures -> New -> but from here whatever I tried I didn't find how to bind Scroll lock to the script.It doesn't give me an option.


Thank you!

Post Reply