How To Solve Any Linux Distributions Brightness Problem ?

I have Acer Aspire 5733 and i couldn’t change brightness of my laptop. This is annoying and painful. I have tried many things to do this but couldn’t solve it as there is no linux graphics driver. At last i have found a solution and i have written an script which will be helpful for you.

 

How_To_Solve_Any_Linux_Distributions_Brightness_Problem.png

To get that script just click here to download or just run below code.

wget --no-check-certificate https://obakfahad.com/extras/brightness.sh -O brightness.sh;chmod a+x brightness.sh;bash brightness.sh

Or you can just read through the codes from below.

#!/bin/bash
PMAM=`date +%p`;

if [[ "$PMAM" = PM ]]; then
echo "It is `date +%p`."
echo ".................................."
TIME=`date +%H%M`

if (( "$TIME" >= 0000 ));then
  echo "It is `date +%T%p`. So brightness should be 70%."
  `xrandr --output LVDS1 --brightness 0.7`
fi
if (( "$TIME" >= 1300 ));then
  echo "It is `date +%T%p`. So brightness should be 70%."
  `xrandr --output LVDS1 --brightness 0.7`
fi
if (( "$TIME" >= 1700));then
  echo "It is `date +%T%p`. So brightness should be 60%."
  `xrandr --output LVDS1 --brightness 0.6`
fi
if (( "$TIME" >= 1830));then
  echo "It is `date +%T%p`. So brightness should be 50%."
  `xrandr --output LVDS1 --brightness 0.5`
fi


fi


if [[ "$PMAM" = AM ]]; then
echo "It is `date +%p`"
echo ".................................."
TIME=`date +%H%M`

if (( "$TIME" >= 0000 ));then
  echo "It is `date +%T%p`. So brightness should be 70%."
  `xrandr --output LVDS1 --brightness 0.5`
fi
if (( "$TIME" >= 1300 ));then
  echo "It is `date +%T%p`. So brightness should be 70%."
  `xrandr --output LVDS1 --brightness 0.5`
fi
if (( "$TIME" >= 1700));then
  echo "It is `date +%T%p`. So brightness should be 60%."
  `xrandr --output LVDS1 --brightness 0.5`
fi
if (( "$TIME" >= 1830));then
  echo "It is `date +%T%p`. So brightness should be 50%."
  `xrandr --output LVDS1 --brightness 0.5`
fi
if (( "$TIME" >= 2000));then
  echo "It is `date +%T%p`. So brightness should be 50%."
  `xrandr --output LVDS1 --brightness 0.6`
fi

You can save that by the name brightness.sh and change permission to execute.

chmod a+x brightness.sh

Automatic Brightness:

You can use crontab to make it automatic.

*/5 * * * * bash /path/to/brightness.sh

It will now act as automatic brightness controller and also above cron will run every 5 minutes.

Conclusion:

Linux and Unix-like operating system may change the default from /var/spool/cron/ to something else. Use the following as a guideline for your OS (assuming that user name is fahad):

  • Mac OS X – /usr/lib/cron/tabs/ (user cron location /usr/lib/cron/tabs/fahad)
  • FreeBSD/OpenBSD/NetBSD – /var/cron/tabs/ (user cron location /var/cron/tabs/fahad)
  • CentOS/Red Hat/RHEL/Fedora/Scientific Linux – /var/spool/cron/ (user cron location /var/spool/cron/fahad)
  • Debian / Ubuntu Linux – /var/spool/cron/crontabs/ (user cron location /var/spool/cron/crontabs/fahad)
  • HP-UX Unix – /var/spool/cron/crontabs/ (user cron location /var/spool/cron/crontabs/fahad)
  • IBM AIX Unix – /var/spool/cron/ (user cron location /var/spool/cron/fahad)

I hope this will be helpful for you. Leave comment for further question or if you have any suggestions. Thank You.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.