Brightmode is a simple Bash script that lets you set two brightness modes for your monitors: Day and Night, using the ddcutil
. It’s lightweight, easy to use, and allows quick switching between preset brightness levels.
You need ddcutil installed for Brightmode to work.
apt install ddcutil
dnf install ddcutil
pacman -S ddcutil
zypper install ddcutil
ddcutil
requires root permissions to access your monitors. To avoid running Brightmode as root every time, we’ll give your user the proper permissions via an i2c
group and a udev
rule.
sudo groupadd i2c
sudo usermod -aG i2c $USER
sudo nano /etc/udev/rules.d/45-ddcutil-i2c.rules
KERNEL=="i2c-[0-9]*", GROUP="i2c", MODE="0660"
sudo udevadm control --reload
sudo udevadm trigger
This ensures your user is part of the i2c
group. After this, you can run Brightmode without needing root privileges or entering your password each time.
To run the script from any directory, move it to a folder in your $PATH
, for example:
sudo mv ./brightmode.sh /usr/local/bin/brightmode
sudo chmod +x /usr/local/bin/brightmode
Using Brightmode is ridiculously simple:
brightmode day
brightmode night
Is the default brightness not quite what you want? Don’t worry. Open the brightmode
file (should be in /usr/local/bin/
) in a text editor (you’ll need root permissions to save changes).
Lines 9
and 10
define the brightness for each mode, where 0 is completely dark and 100 is maximum brightness. Adjust these values as desired and save the file.
Need more brightness modes? Want to change other settings like contrast or gamma? You can get creative and use brightmode
as a template to add more options. The sky’s the limit!
Since ddcutil
allows many possibilities (seriously, Sanford Rockowitz is a genius!), we’ll focus on brightness profiles. Open /usr/local/bin/brightmode
and let’s add a new profile called BRIGHTNESS_AFTERNOON
(intermediate between day and night):
Below line 10
(BRIGHTNESS_NIGHT=10
) add your new profile:
# Configure the brightness values for each mode
BRIGHTNESS_DAY=50
BRIGHTNESS_NIGHT=10
BRIGHTNESS_AFTERNOON=30
#--------------------
Change the usage line:
echo "Usage: brightmode <day|night>"
To:
echo "Usage: brightmode <day|night|afternoon>"
Add a condition for your new profile:
if [ $1 == "day" ]; then
BRIGHT=$BRIGHTNESS_DAY
elif [ $1 == "night" ]; then
BRIGHT=$BRIGHTNESS_NIGHT
elif [ $1 == "afternoon" ]; then
BRIGHT=$BRIGHTNESS_AFTERNOON
else
echo -e "${RED}Error: mode \"$1\" is not allowed! Options: \"day\", \"night\" or \"afternoon\"${NC}"
exit 1
fi
What happens if we add many brightness profiles? That if
is gonna be a mess, but I’ll let you sort it out. 😉
After saving, you can run your new profile:
brightmode afternoon
Honestly, it’s hard to imagine this script causing any issues, but you can report bugs via the Issue Tracker. If you can think of any improvements (there is plenty of room for them) or anything new that this script could do, that is also welcome 🤓
Seriously, this README is longer than the script itself…