I run Ubuntu 16.04 on an Acer Aspire E5-773G notebook. Unfortunately, I can not use my brightness function keys on the login screen, so the first moment when I am able to change my screen backlight brightness is after successfully entering my password and logging in.
By default, Ubuntu boots with the brightness level that has been set at the last shutdown, but this is not very useful as e.g. sometimes I shut down late at night with a brightness level around 5% and start it up again the next day where I would need a brightness level of at least 50% to comfortably see everything. The other way round, if I shut down during the day with maybe 80% brightness and boot it up in the evening, I nearly get blinded by the lights…
How can I configure Ubuntu to boot with a brightness level depending on the current daytime? I would like something like 10% brightness from 22:00 to 06:00, 60% brightness from 10:00 to 16:00 and 30% brightness in between. Smoothing the curve is okay, as long as it stays easily configurable. Alternatively, if you find a way to set it based on local sunset/sunrise times, that would be a big bonus. 🙂
Modifying brightness according to these rules should only take place during boot or optionally when waking up from suspend. It may not automatically change brightness while I'm working.
Best Answer
Basic idea:
Save configuration file
/opt/.time_brightness_values
:Pay attention to quoted values and commas. First column with quoted values represents hour range in 24 hour format, the second column is percentage. For example, if you booted from 5 to 7 o'clock your brightness would be set to 25 percent. If you booted from 8 to 16 o'clock, it would be 50 percent.
Save the script below as
/opt/set_timed_brightness.py
Set
greeter-setup-script=/opt/set_timed_brightness.py
in the/etc/lightdm/lightdm.conf
file. The greeter setup script runs as root and once your system gets up to the login screen, the script will run and set the brightness you need.As far as waking up from suspend goes, create
/etc/pm/sleep.d/set_timed_brightness.sh
:Remember: all the standard rules apply, the scripts must be made executable with
chmod +x
, naming and calls to each file have to be consistent.