Ever got blinded by a sudden blast of light mode? Well this programs aims to eliminate just that by automatically setting your brightness to a lower value when the content on your screen is brighter and higher when the contents are darker. It works for any number of screens.
- Takes all the pixels on the screen
- Converts all of them to greyscale (with weighted rgb values)
- Averages the 'whiteness' of each pixel (range- 0 to 255)
- Repeats this in some interval (every
refreshRate
seconds) - Compares it with the previous value
- If the change in whiteness is above a threshold, calculates an appropriate brightness and prints it
- Changes the brightness of the monitor accordingly [Only for Linux and Windows]
- Does all this with every connected monitor
Add ability for this program to change brightness[Mac is still not implemented tho]Add flags to configure parametersWindows Testing- MacOS Testing
- Make the transition smooth
- Get rid of the
brightnessctl
dependency on Linux - Disable it when videos are being played
- Add support for changing brightness on macOS (currently you can use this program in combination with apple script)
AutoBrightnessAdjuster requires that brightnessctl
be installed.
A direct implementation on linux would have simply included editing /sys/class/backlight/< Name of Display >/brightness
but that would have required sudo access which I felt was dangerous.
Some programs like brightnessctl
and light
seem to add udev rules to get write access to the file, but I don't understand how exactly that works. I decided to go with brightnessctl
because it is available in the extra
repo of Arch (plus I already use it lol). This is in my TODO.
golang is needed to build, but is not a runtime dependency.
Prebuilt binaries for Linux, Windows and MacOS can be found in Releases.
Otherwise you can build it yourself from the instructions below.
First ensure that you have go
installed
Clone this repo and move into the cloned directory
git clone 'https://github.com/code-IM-perfect/AutoBrightness'
cd AutoBrightness
Now just run
go build -o autoBrightness .
Or for windows-
go build -o autoBrightness.exe .
This will download all the required go dependencies (if not already intsalled) and will build the program.
After building, it can be used by
./autoBrightness <<Options>>
./autoBrightness --mid 20 --deviate 10
Set the Maximum Deviation from the normal brightness (default 20)
Set the Normal Brightness (0-100) (default 30)
Set the Rescan Rate (0.5 == rescan every 0.5 sec to refresh) (default 0.5)
Set the treshold used while deciding if the change in lightness is large enough (implementaion is complicated, so find an appropriate value by experimenting) (default 3)