0

I'd like to make screen brightness lower on low battery. There's no such options in power settings. Alternatively, I may set the system to shut down in such situation, but that's undesired. Is there any kind of script or bash command that I could use to set lower screen brightness on low battery?

2
  • Which Desktop Environment do you use?
    – dr_
    Jun 20, 2019 at 8:05
  • Cinnamon desktop.
    – Dune
    Jun 20, 2019 at 9:49

1 Answer 1

1
sudo apt-get install xbacklight

and give this a try

#!/bin/bash

lowBatLevel=25 #battery percent considered low
desiredBrightness=25 #brightness level to lower to ( 0 to 100 )
batLevel=`upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep percentage | awk '{print $2}'  | sed 's/.$//'`
curBrightness=`xbacklight -get`

if    [ $curBrightness -gt $desiredBrightness ]  && [ $batLevel -le $lowBatLevel ]  ; then #change 25 to your desired battery % 
xbacklight -set $desiredBrightness
fi

I'm not on a linux machine so I have not tested, let me know if you have any errors

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .