Linux – turn on/off backlit “xset led 3” with “scroll lock”

backlightkali-linuxkeyboardlinux

i'm buy a mechanical keyboard for my computer, i'm using kali linux rolling 2016.2
i'm forget to read the compatible driver for my keyboard.and that's only compatible in windows 10 and mac.
after i'm searching "how to enable backlit keyboard on linux" i found the answer. he said i shoul run on terminal "sudo xset led 3" and its work, but i dont know how to turn off it again.
my question is, how to turn on the backlit using key"schroll lock" and that's command is same with running "sudo xset led 3" in terminal.

Best Answer

LED ON

sudo xset led 3

LED OFF

sudo xset -led 3

A script to toggle LED On/Off with the "Scroll Lock" key:

#!/bin/bash
on=$(xset -q | grep 'Scroll Lock:' | cut -d ":" -f 7)
echo $on
if [ $on == "off" ]; then
   xset led named "Scroll Lock"
else
   xset -led named "Scroll Lock"
fi  

Save it and bind to a key with a shortcut.

Sources:

xset Man page: ftp://www.x.org/pub/X11R7.5/doc/man/man1/xset.1.html

Forums: http://www.forosuse.org/forosuse/showthread.php?t=33563

Related Question