Script for maintaining brightness on Lenovo G405

I observed that the this AMD A4 powered laptop has two backlight classes names idepad and radeon-bl0. Pressing the brightness keys changes brightness values in idepad class while values in radeon-bl0 needs to be changed.
So I wrote a script which will keep the two files in sync and help me get the brightness working.

syncBrightness.sh

#!/bin/bash
# Script to sync brightness from sys/classes/idepad to /sys/classes/radeon-bl0
# Task: run in a loop executed every second,  modify radeon  brightness acccording to ideapad brightness
# ideapad brightness from 1 to 16 in steps of 1;
# Radeon brightness 1 to 255 in steps of 1;
while [ 1 -eq 1 ]
do
IBRIGHTNESS=`cat /sys/class/backlight/ideapad/brightness`
if [ $IBRIGHTNESS -le 1 ]
then
IBRIGHTNESS=1
fi
echo "Ideapad Brightness: $IBRIGHTNESS"
let RBRIGHTNESS=$IBRIGHTNESS*16-1
echo "Radeon Brightness to be set: $RBRIGHTNESS"
echo $RBRIGHTNESS>/sys/class/backlight/radeon_bl0/brightness
sleep 1
done

Comments

Popular posts from this blog

Morning Quotes

QCalendarWidget CSS Stylesheeting