You are not logged in.

#1 2019-07-21 03:30:49

keiichiiownsu12
Member
Registered: 2019-04-16
Posts: 42

[Solved] Setting up and adjusting a backlit-keyboard Time-Out interval

The keyboard backlight on my ASUS  S410UN-NS74 works just fine and is able to be adjusted/turned off. I was wondering if there was a verified method to setup a Time-Out interval for the keyboard backlight? I.e. turn it off when not typing, turn on when a key is pressed.

Dell posted a topic on how to do this on Ubuntu for the XPS developer edition here , so I figured why not see what files would be there for an ASUS laptop. In /sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight, there doesn't seem to be any relevant files. All files in ./power, i.e.

$ls /sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight/power /
async                 runtime_active_kids  runtime_status
autosuspend_delay_ms  runtime_active_time  runtime_suspended_time
control               runtime_enabled      runtime_usage

showed "unsupported" as their contents, which I read (somewhere) that this means something along the lines of that some of the hardware is unsupported by the asus-nb-wmi module.

I am reading on https://vignesh.co/blog/setting-keyboar … eout-linux that I can create a custom script and systemd daemon to do this. There is also a package on the AUR called asus-kbd-backlight that lets you adjust the keyboard LEDs via the command line, which I assume is easy to program into a script.

Apart from those two options, is there another, potentially more "elegant" or efficient method for enabling a keyboard backlight time-out?

Last edited by keiichiiownsu12 (2019-07-21 04:47:14)


I, uh, nevermind

Offline

#2 2019-07-21 04:46:24

keiichiiownsu12
Member
Registered: 2019-04-16
Posts: 42

Re: [Solved] Setting up and adjusting a backlit-keyboard Time-Out interval

So I used the method on https://vignesh.co/blog/setting-keyboar … eout-linux by creating a script and a systemd service. Works fairly fine. I changed his script slightly, making it use the asus-kbd-backlight command. The modified script is as follows:

#!/bin/bash
idle=false
idleAfter=10000 #edit this x with the timeout in milliseconds
savedState=0
while true; do
  idleTimeMillis=$(sudo -u $user env DISPLAY=:0.0 xprintidle)
  if [[ $idle = false && $idleTimeMillis -gt $idleAfter ]] ; then
 savedState=$(cat /sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight/brightness)
 sudo asus-kbd-backlight 0 #/bin/sh -c "echo 0 >> /sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight/brightness"
 idle=true
 echo "Keyboard dimmed."
  fi
  if [[ $idle = true && $idleTimeMillis -lt $idleAfter ]] ; then
 sudo asus-kbd-backlight $savedState #/bin/sh -c "echo $savedState >> /sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight/brightness"
 idle=false
 echo "Keyboard brightened."
  fi
  sleep 1
done

replace the $user variable with your relevant username. Enter time in milliseconds in the idleAfter variable.  Commented out lines in sudo were the original commands which I replaced with asus-kbd-backlight. Honestly, you can just use the original commands the creator used. Make sure you change the directories to point to your appropriate keyboard "brightness" file. After you create that, create a systemd service, like the guy mentioned, then enable/start it. Works like a charm.

If anyone has any other potentially more efficient/elegant solutions, please let me know!

Last edited by keiichiiownsu12 (2019-07-21 04:54:20)


I, uh, nevermind

Offline

Board footer

Powered by FluxBB