[Solved] CLI Command for Keyboard Background Lightning

Questions about hardware,drivers and peripherals
Forum rules
Before you post please read how to get help

[Solved] CLI Command for Keyboard Background Lightning

Postby drmccoy on Thu Jul 18, 2013 10:41 am

Hi guys,

currently running Cinnamon Mint 15 on an Asus N76VZ which features Background Lightning on the Keyboard. It comes with FN commands which worked out of the box on Mint.
Now problem is, they background lightning is off when I boot into Mint, and I have to do the FN+F4 a couple of times to get it running. I was wondering whether anybody could tell me the CLI Commands for keyboard illumination, so I could just create a small sh script that is called on the auto start programs which will automaticly illuminate my keyboard?

Hope anybody can help with this issue, google has not been very responsive on that issue. I'm pretty sure Cinnamon Mint does recognize the FN+F3/F4 Keystores, because I get a little icon displayed plus a bar signalling the current intensity of the illumination when I press them.
Last edited by drmccoy on Wed Jul 31, 2013 6:40 am, edited 1 time in total.
drmccoy
Level 1
Level 1
 
Posts: 10
Joined: Fri Nov 02, 2012 5:08 am

Linux Mint is funded by ads and donations.
 

Re: CLI Command for Keyboard Background Lightning

Postby roblm on Sun Jul 21, 2013 10:46 am

Can you post the result of running this command in the Terminal:

cat /sys/class/leds/asus::kbd_backlight/max_brightness
Last edited by roblm on Thu Aug 01, 2013 1:13 pm, edited 1 time in total.
User avatar
roblm
Level 5
Level 5
 
Posts: 760
Joined: Sun Feb 24, 2013 2:41 pm

Re: CLI Command for Keyboard Background Lightning

Postby drmccoy on Wed Jul 24, 2013 8:16 am

roblm wrote:Can you post the result of running this command in the Terminal:

cat: /sys/class/leds/asus::kbd_backlight/max_brightness


Code: Select all
$ cat /sys/class/leds/asus\:\:kbd_backlight/max_brightness
3


Does this help you?

EDIT:

Okay, I found out that you can control the current background lightning via the value in the file /sys/class/leds/asus::kbd_backlight/brightness
But I'm stuck finding an automated way of controlling the value.
If I do a nano brightness, edit the value and save the file, the behaviour picks up nicely and the lightning is adapted

However, doing a cat /dev/null > brightness && cat "2" > brightness won't work, because of 'File or Directory not found', same thing for cp brightness brightness.bak or a simple touch test.
Same goes for all commands executed via SUDO.

Either way (directly removing contents of the file and adding the desired value, or keeping two files (one with 0 and one with 3) and substituting the actual brightness file with the one thats containing the needed value will do fine. But neither work, not due to 'restriction' but due to 'File or Directory not found' ?

Any help on this issue?
drmccoy
Level 1
Level 1
 
Posts: 10
Joined: Fri Nov 02, 2012 5:08 am

Re: CLI Command for Keyboard Background Lightning

Postby roblm on Wed Jul 24, 2013 11:50 am

Do the Fn+F3 and Fn+F4 function keys actually work in increasing and decreasing the keyboard backlight?

Does running the following command turn on the backlight:
echo 3 > /sys/class/leds/asus::kbd_backlight/brightness

If that doesn't work try this:
echo 3 | sudo tee /sys/class/leds/asus::kbd_backlight/brightness
User avatar
roblm
Level 5
Level 5
 
Posts: 760
Joined: Sun Feb 24, 2013 2:41 pm

Re: CLI Command for Keyboard Background Lightning

Postby drmccoy on Thu Jul 25, 2013 4:23 pm

roblm wrote:Do the Fn+F3 and Fn+F4 function keys actually work in increasing and decreasing the keyboard backlight?

Yes, they work just as they should. I even get a little popup layer whenever I press them, showing me the current brightness level.



roblm wrote:Does running the following command turn on the backlight:
echo 3 > /sys/class/leds/asus::kbd_backlight/brightness


Unfortunatelly, I get a restricted access error. Even if run as sudo.

roblm wrote:If that doesn't work try this:
echo 3 | sudo tee /sys/class/leds/asus::kbd_backlight/brightness


I have no idea how or why, but this really does work. Only downside is, it does require root privilidges. Any ideas on how to run that command automated after I logon (without having to enter my root pw every time)?
drmccoy
Level 1
Level 1
 
Posts: 10
Joined: Fri Nov 02, 2012 5:08 am

Re: CLI Command for Keyboard Background Lightning

Postby roblm on Fri Jul 26, 2013 9:24 am

Right now only root can read and write to the file: /sys/class/leds/asus::kbd_backlight/brightness
The permissions need to be changed to allow others to write to it. In the Terminal type:
sudo chmod a+rw /sys/class/leds/asus::kbd_backlight/brightness

Then try running this command again: echo 3 > /sys/class/leds/asus::kbd_backlight/brightness

If it now works then make a script with that command. Open Nemo in your Home directory (/home/user-name) and right click in the empty space and select “Create New Document” > “Empty Document”. Name the file “.keyboard-backlight” or whatever. If you want to, then you can put a dot in front of it so it is hidden. Open the file and add these lines:

#!/bin/sh
echo 3 > /sys/class/leds/asus::kbd_backlight/brightness

Save the file. Then right click on it and select > Properties > Permissions, and check the box next to “Allow executing file as program”. Test the file in the Terminal by typing: sh .keyboard-backlight
Last edited by roblm on Mon Oct 21, 2013 8:27 am, edited 2 times in total.
User avatar
roblm
Level 5
Level 5
 
Posts: 760
Joined: Sun Feb 24, 2013 2:41 pm

Re: CLI Command for Keyboard Background Lightning

Postby drmccoy on Wed Jul 31, 2013 6:40 am

I added it to the actual start script file that's being called right after I logon, it's working like a charm now.
Thanks again for your helpful support!
drmccoy
Level 1
Level 1
 
Posts: 10
Joined: Fri Nov 02, 2012 5:08 am

Re: [Solved] CLI Command for Keyboard Background Lightning

Postby james3 on Sun Oct 20, 2013 11:01 am

I have almost everything as drmccoy but the fn+F3 or F4 just show me the Backlight Keyboard regulation Logo on screen but don't regulate or turn ON/OFF the keyboard.
If I do that manually I'm able to regulate-turn ON/OFF the keyobard.

Is there a way to fix the fn+F3 F4 shortcut so I can regulate with these keyboard combination my Backlight Keyboard ?

My problem is described here in the forum too viewtopic.php?f=90&t=147998

thanks
james3
Level 1
Level 1
 
Posts: 8
Joined: Tue Dec 18, 2012 12:24 pm

Re: [Solved] CLI Command for Keyboard Background Lightning

Postby roblm on Mon Oct 21, 2013 8:30 am

james3,

Your problem isn't the same as drmccoy had, so a separate topic probably should have been started.
You can try a method using the udev kernel event manager that has worked on Samsung laptops that had no keyboard backlight
control but I don't know if it will work for your Asus laptop. Information about using this method is in the links below:

http://natjohan.info/linux-on-samsung-np900x3c.html
http://jablonskis.org/2012/linux-and-sa ... 9-fn-keys/

Here's the information needed. Type this command in the Terminal and post the result:
cat /sys/class/dmi/id/product_name

Then press Ctrl+Alt+F1 to enter the virtual console tty1 and type: /lib/udev/findkeyboards
Get the input/event number of the AT keyboard.

Then type: sudo /lib/udev/keymap -i input/eventX
where X is the number you found in the previous step.

Press the Fn+F3 and then Fn+F4 function key combinations.
Press the Escape key.
You can't use the print screen function here, so use the command:
sudo screendump 1 > screenoutput.txt

Press Ctrl+Alt+F8 to exit the tty1 console. If this fails then try Ctrl+Alt+F7.
The file "screenoutput.txt" will be found in your "/home/username" directory.
These are the scancodes generated when pressing the backlight function keys. Post the result.
Last edited by roblm on Wed Oct 23, 2013 12:06 pm, edited 1 time in total.
User avatar
roblm
Level 5
Level 5
 
Posts: 760
Joined: Sun Feb 24, 2013 2:41 pm

Re: [Solved] CLI Command for Keyboard Background Lightning

Postby james3 on Tue Oct 22, 2013 3:25 am

thanks for your reply
here are the information needed

Code: Select all
alex@alex-N56VZ ~ $ cat /sys/class/dmi/id/product_name
N56VZ


Linux Mint 15 Olivia alex-N56VZ tty1
alex-N56VZ login: alex
Password:
Last login: Tue Oct 22 09:11:12 CEST 2013 on tty1
Welcome to Linux Mint 15 Olivia (GNU/Linux 3.8.0-19-generic x86_64)

Welcome to Linux Mint
 * Documentation:  http://www.linuxmint.com

21 packages can be updated.
0 updates are security updates.

alex@alex-N56VZ ~ $ /lib/udev/findkeyboards
USB keyboard: input/event11
USB keyboard: input/mouse1
AT keyboard: input/event3
alex@alex-N56VZ ~ $ sudo /lib/udev/keymap -i input/event3
[sudo] password for alex:
Press ESC to finish, or Control-C if this device is not your primary keyboard
^@^@^@^@^@^@scan code: 0x1D   key code: leftctrl
scan code: 0x1D   key code: leftctrl
scan code: 0x1D   key code: leftctrl
scan code: 0x01   key code: esc
alex@alex-N56VZ ~ $ sudo screendump 1 > dump.txt
james3
Level 1
Level 1
 
Posts: 8
Joined: Tue Dec 18, 2012 12:24 pm

Re: [Solved] CLI Command for Keyboard Background Lightning

Postby roblm on Tue Oct 22, 2013 8:48 am

Instead of showing different scancodes when pressing Fn+F3 and Fn+F4, your result shows the same scancode, which is mapped to the
left control key.

Here is an example of what I was expecting to see when pressing the function keys for keyboard illumination down and up:
scan code: 0x97 key code: kbdillumdown
scan code: 0x96 key code: kbdillumup

Could you repeat the previous step and press all the function key combinations starting with Fn+F1 all the way through Fn+F12 and post
the output.
User avatar
roblm
Level 5
Level 5
 
Posts: 760
Joined: Sun Feb 24, 2013 2:41 pm

Re: [Solved] CLI Command for Keyboard Background Lightning

Postby james3 on Tue Oct 22, 2013 9:50 am

When I press fn+F3 or fn+F4 the result is always for both : "^@"

then I pressed leftctr + alt F8 without pressin esc because I was attempting to switch to the X enviroent this is the reasone cos you readed leftctrl

anyway below I did the last part again step by step
thanks

[code]Linux Mint 15 Olivia alex-N56VZ tty1
alex-N56VZ login: alex
Password:
Last login: Tue Oct 22 09:18:00 CEST 2013 on tty1
Welcome to Linux Mint 15 Olivia (GNU/Linux 3.8.0-19-generic x86_64)

Welcome to Linux Mint
* Documentation: http://www.linuxmint.com

21 packages can be updated.
0 updates are security updates.

alex@alex-N56VZ ~ $ sudo /lib/udev/keymap -i input/event3
[sudo] password for alex:
Press ESC to finish, or Control-C if this device is not your primary keyboard
fn+F1= ^@
then the system suspended as it should IT WORKS OK

fn+F2= nothing
nothing happened (the wi-fi should turn OFF)

fn+F3= ^@
nothing happened (the backlight keyboard should decrease)

fn+F4= ^@
nothing happened (the backlight keyboard should increase)

fn+F5= ^@
Backlight screen decrease it works OK

fn+F6= ^@
Backlight screen increase it works OK

fn+F7= ^@
screen turn OFF it works OK


fn+F8 = scan code: 0xDB key code: leftmeta
scan code: 0x19 key code: p
nothing happened (the screen should switch to projector)


fn+F9=^@
switch touchpad OFF it works OK

fn+F10= scan code: 0xA0 key code: mute
it works OK

fn+F11= scan code: 0xAE key code: volumedown
it works OK

fn+F12= scan code: 0xB0 key code: volumeup
it works OK
james3
Level 1
Level 1
 
Posts: 8
Joined: Tue Dec 18, 2012 12:24 pm

Re: [Solved] CLI Command for Keyboard Background Lightning

Postby roblm on Wed Oct 23, 2013 12:06 pm

Try loading the asus-nb-wmi kernel module with this command and then check the function of the keyboard backlight:
modprobe asus-nb-wmi

If the kernel is correctly recognizing the function keys that are pressed then a scancode should be generated, which is then mapped
to a keycode. This can be clearly seen when you pressed Fn+F8, Fn+F10, Fn+F11 and Fn+F12. Without the scancodes we can't
progress to the next step. You may need to add a kernel boot parameter to the grub boot file for all the function keys to be recognized.
Open the file with this command: gksudo gedit /etc/default/grub
Change the line: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" to the top line below, save the file and then run the command:
sudo update-grub

GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash acpi_osi=Linux”
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_osi='!Windows 2012'"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_backlight=vendor"
GRUB_CMDLINE_LINUX_DEFAULT="acpi_osi="

Reboot and retest the keyboard backlight. If no success then enter the tty1 console again and repeat the steps in a previous post to get
scancodes for Fn+F3 and Fn+F4. Repeat this process for all four lines above.

If this fails, then you could try the showkey utility to see if it can show the scancodes. Enter the tty1 virtual console and type: showkey -s
Press Fn+F3 and then Fn+F4
Wait 10 seconds for the program to end.
Get a screenshot with the command: sudo screendump 1 > screenoutput.txt

Do you have a USB mouse and some other USB device attached? In a previous post when you ran the command "/lib/udev/findkeyboards"
the output showed:
USB keyboard: input/event11
USB keyboard: input/mouse1
AT keyboard: input/event3
User avatar
roblm
Level 5
Level 5
 
Posts: 760
Joined: Sun Feb 24, 2013 2:41 pm

Re: [Solved] CLI Command for Keyboard Background Lightning

Postby james3 on Wed Oct 23, 2013 12:26 pm

roblm wrote:Try loading the asus-nb-wmi kernel module with this command and then check the function of the keyboard backlight:
modprobe asus-nb-wmi

If the kernel is correctly recognizing the function keys that are pressed then a scancode should be generated, which is then mapped
to a keycode. This can be clearly seen when you pressed Fn+F8, Fn+F10, Fn+F11 and Fn+F12. Without the scancodes we can't
progress to the next step.


Code: Select all
alex@alex-N56VZ ~ $ modprobe asus-nb-wmi
alex@alex-N56VZ ~ $ sudo /lib/udev/keymap -i input/event3
Press ESC to finish, or Control-C if this device is not your primary keyboard
^@^@
scan code: 0x01   key code: esc   
alex@alex-N56VZ ~ $ showkey -s
la modalit della tastiera era UNICODE
[ Se questo tentativo viene effettuato usando X potrebbe non
funzionare, dato che anche il server X sta leggendo /dev/console ]

premere un tasto (il programma terminer 10s dopo l'ultima pressione del tasto)...
0x9c
0xe0 0x58 0xe0 0xd8 = fn+F3
0xe0 0x59 0xe0 0xd9 = fn+F4
alex@alex-N56VZ ~ $ sudo /lib/udev/keymap -i input/event3
Press ESC to finish, or Control-C if this device is not your primary keyboard
^@^@scan code: 0x01   key code: esc
alex@alex-N56VZ ~ $ sudo screendump 1 > dump3.txt
james3
Level 1
Level 1
 
Posts: 8
Joined: Tue Dec 18, 2012 12:24 pm

Re: [Solved] CLI Command for Keyboard Background Lightning

Postby roblm on Wed Oct 23, 2013 3:27 pm

Could you use showkey again for the Fn+F11 and Fn+F12 key combinations in the tty1 virtual console.
The output from using showkey is different from using the command "/lib/udev/keymap -i input/event3".

Also run this command in the Terminal: cat /sys/class/dmi/id/sys_vendor
User avatar
roblm
Level 5
Level 5
 
Posts: 760
Joined: Sun Feb 24, 2013 2:41 pm

Re: [Solved] CLI Command for Keyboard Background Lightning

Postby james3 on Thu Oct 24, 2013 4:12 am

Code: Select all
alex@alex-N56VZ ~ $ cat /sys/class/dmi/id/sys_vendor
ASUSTeK COMPUTER INC.


ctrl+alt+F1


Code: Select all
alex@alex-N56VZ ~ $ showkey -s
la modalit della tastiera era UNICODE
[ Se questo tentativo viene effettuato usando X potrebbe non
funzionare, dato che anche il server X sta leggendo /dev/console ]

premere un tasto (il programma terminer 10s dopo l'ultima pressione del tasto)...
0xe0 0x2e 0xe0 0xae = fn+F11
0xe0 0x30 0xe0 0xb0 = fn+F12
alex@alex-N56VZ ~ $ sudo screendump 1 > dump4.txt
[sudo] password for alex:
james3
Level 1
Level 1
 
Posts: 8
Joined: Tue Dec 18, 2012 12:24 pm

Re: [Solved] CLI Command for Keyboard Background Lightning

Postby roblm on Thu Oct 24, 2013 8:37 pm

Now a decision must be made for the scan codes to use for Fn+F3 and Fn+F4. From using showkey the scancodes for Fn+F3 were:
0xe0 0x58 0xe0 0xd8
0xe0 0x58 was generated when the key was pressed and 0xe0 0xd8 when the key was released. The 0xe0 is just a so called prefix.

Looking at the results from Fn+F11, the scancode from using "/lib/udev/keymap -i input/event3" was 0xAE, with the letters being
capitalized, and using showkey was 0xe0 0x2e 0xe0 0xae. The key release scancode 0xae is the same but the letters are not
capitalized. If you look at the keymap files in "/lib/udev/keymaps", all of the scancode letters are capitalized. I've always used the scancodes obtained from the "/lib/udev/keymaps -i input/event#" command.
I suggest first trying the scancodes 0x58 for Fn+F3 and 0x59 for Fn+F4

First copy these two lines containing the scancodes:

0x58 kbdillumdown #Fn+F3 Keyboard backlight down
0x59 kbdillumup #Fn+F4 Keyboard backlight up

Then create a udev keymaps file named “Asus-N56VZ” in “/lib/udev/keymaps” with this command:
gksudo gedit /lib/udev/keymaps/Asus-N56VZ
Paste the copied lines and save the file.

Then copy these lines:

0x58 #Fn+F3 Keyboard backlight down
0x59 #Fn+F4 Keyboard backlight up

Then create a udev file named “Asus-N56VZ” in "/lib/udev/keymaps/force-release" with this command:
gksudo gedit /lib/udev/keymaps/force-release/Asus-N56VZ
Paste the copied lines and save the file.

Then copy the following udev rule:

ENV{DMI_VENDOR}=="ASUS*", ATTR{[dmi/id]product_name}=="*N56VZ*", RUN+="keymap $name Asus-N56VZ”

Open the “95-keymap.rules” file with this command:
gksudo gedit "/lib/udev/rules.d/95-keymap.rules file"

Paste the copied line below this line, which is at the bottom section of the file:
ENV{DMI_VENDOR}=="ASUS", RUN+="keymap $name asus"
Save the file.

Then copy the following udev rule:
ENV{DMI_VENDOR}=="ASUS*", ATTR{[dmi/id]product_name}=="*N56VZ*", RUN+="keyboard-force-release.sh $devpath Asus-N56VZ"

Open the “95-keyboard-force-release.rules” file with this command:
gksudo gedit /lib/udev/rules.d/95-keyboard-force-release.rules

Paste the copied line below this line:
ENV{DMI_VENDOR}="$attr{[dmi/id]sys_vendor}"

Save the file and then run this command in the Terminal: sudo adevadm trigger
Reboot and test the backlight. If there is no change then try using these scancodes in the two files created above:

0xd8 kbdillumdown #Fn+F3 Keyboard backlight down
0xd9 kbdillumup #Fn+F4 Keyboard backlight up

0xd8 #Fn+F3 Keyboard backlight down
0xd9 #Fn+F4 Keyboard backlight up

If that doesn't work then try:

0xD8 kbdillumdown #Fn+F3 Keyboard backlight down
0xD9 kbdillumup #Fn+F4 Keyboard backlight up

0xD8 #Fn+F3 Keyboard backlight down
0xD9 #Fn+F4 Keyboard backlight up
User avatar
roblm
Level 5
Level 5
 
Posts: 760
Joined: Sun Feb 24, 2013 2:41 pm

Linux Mint is funded by ads and donations.
 

Return to Hardware Support

Who is online

Users browsing this forum: No registered users and 12 guests