Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script for controlling the backlight in the ASUS G74SX
#!/bin/bash
#
# Brightness script for the ASUS G74SX
#
# Arguments:
# up - increase brightness by 1
# down - decrease brightness by 1
#
BRIGHTNESS=`cat /sys/devices/platform/asus-nb-wmi/leds/asus\:\:kbd_backlight/brightness`
MAX_BRIGHT=`cat /sys/devices/platform/asus-nb-wmi/leds/asus\:\:kbd_backlight/max_brightness`
# Try to recover brightness setting (since the `cat` seems to always return 0)
if [ -f /tmp/keyboard-brightness-ctl ]
then
BRIGHTNESS=`cat /tmp/keyboard-brightness-ctl`
fi
case "$1" in
up)
BRIGHTNESS=$((BRIGHTNESS + 1))
if [ $BRIGHTNESS -gt $MAX_BRIGHT ] ; then BRIGHTNESS=$MAX_BRIGHT ; fi
echo $BRIGHTNESS > /tmp/keyboard-brightness-ctl
echo $BRIGHTNESS > /sys/devices/platform/asus-nb-wmi/leds/asus\:\:kbd_backlight/brightness
;;
down)
BRIGHTNESS=$((BRIGHTNESS - 1))
if [ $BRIGHTNESS -lt 0 ] ; then BRIGHTNESS=0 ; fi
echo $BRIGHTNESS > /tmp/keyboard-brightness-ctl
echo $BRIGHTNESS > /sys/devices/platform/asus-nb-wmi/leds/asus\:\:kbd_backlight/brightness
;;
esac
@junf

This comment has been minimized.

junf commented Nov 3, 2013

Thank you for this useful script. This was also valid for my ASUS G75VW too.

@mangus

This comment has been minimized.

mangus commented Feb 23, 2014

Thanks for the script! Works also with Asus UX301!

Anybody knows how to make it work without root permissions? I can change the owner of the "/sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight/brightness" file, so that it wouldn't need root permission, but after restart the owner is still root...

@Insanity2122

This comment has been minimized.

Insanity2122 commented Sep 12, 2017

I'm not sure how to use scripts, but I'm trying to change my rog strix from red backlight to a teal kind of color, like I did with my mouse. Do you people know how to help me do that? If it only works with scripts please explain it to me I've searched everywhere with no soultion

@Insanity2122

This comment has been minimized.

Insanity2122 commented Sep 12, 2017

This is the code for the color of my mouse if you need it to help me, if you decide to. #00eaff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment