playing with brightness on screensaver

Christophe Colombier - Aug 10 '22 - - Dev Community

I wanted to decrease the brightness of the screen when my screen was locked.

here is the script I used to lock my screen with xautolock.

It calls i3lock, but it could be anything.

I'm using xrandr to get the screen name and decrease the brightness, then restore it on exit.

#!/bin/sh

set -e

primary=$(xrandr | grep " primary" | cut -f1 -d " " | head -n 1)

on_exit() {
  xrandr --output $primary --gamma 1 --brightness 1
}
trap on_exit EXIT

xrandr --output $primary --brightness 0.8 --gamma 0.8

# enable the lock screen
i3lock --nofork -c 272d2d -i ~Documents/wallpaper-lockscreen.png
Enter fullscreen mode Exit fullscreen mode

Here again it's important to use --nofork parameter with i3lock

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .