You are not logged in.
Pages: 1
I create this simple script to set nocturne light in my window manager using xrandr.
#!/bin/sh
set_gamma() {
for monitor in $(xrandr --listmonitors | awk 'NR>1 {print $NF}'); do
xrandr --output "$monitor" --gamma "$1"
done
}
if xrandr --verbose | grep -q "Gamma: *1.0:1.0:1.0"; then
gamma="1:1:0.5"
else
gamma="1:1:1"
fi
set_gamma "$gamma"
Do you know a better solution or program to use?
Offline
Finally, I improved the script to incorporate the red light, which scientists recommend.
#!/bin/sh
NIGHT="1.0:1.0:0.5"
NORMAL="1.0:1.0:1.0"
RED="1.0:0.5:0.5"
usage() {
printf '%s\n' "usage: nocturne [-r|--red]"
}
set_gamma() {
for monitor in $(xrandr --listmonitors | awk 'NR>1 {print $NF}'); do
xrandr --output "$monitor" --gamma "$gamma"
done
}
while :; do
case "$1" in
-h | --h | --he | --hel | --help)
usage
exit 0
;;
-r | --red)
gamma="$RED"
;;
-*)
print_error "Unknown option: $1"
usage
exit 1
;;
*)
break
;;
esac
shift
done
actual="$(xrandr --verbose | awk '/Gamma/ {print $2}')"
if [ "$actual" = "$NORMAL" ]; then
[ -z "$gamma" ] && gamma="$NIGHT"
else
gamma="$NORMAL"
fi
if [ "$gamma" != "$actual" ]; then
set_gamma "$gamma"
fi
Offline
Offline
I had seen it, but all those localization options scared me. I preferred the simple alternative using xrandr. I've been using the red light for a few days and I can hold out a bit longer now in front of the computer.
By the way, I had forgotten to define the print_error function.
print_error() {
printf '\e[1;38;5;1m%s\e[m\n' "$1" >&2
}
Offline
I had seen it, but all those localization options scared me.
?
You tell it your geolocation so it can calculate the daylight timeframe, https://wiki.archlinux.org/title/Redshi … n_manually doesn't require any online queries.
But you don't acutally have to, you can just define dusk and dawn time (though that's cumbersome): https://man.archlinux.org/man/extra/red … #dawn_time
If you're super-worried about typing your geolocation anywhere, flipping the lattitude won't change anything about the sunrise/set and you can also invert the temperatures and brightness and rotate your longitude by 180°
Edit: that's obviously wrong and dumb and I need more sleep.
Last edited by seth (2024-12-07 21:54:45)
Offline
It doesn't work for multiple monitors. The solution is to return the first occurrence with awk.
actual="$(xrandr --verbose | awk '/Gamma/ {print $2; exit}')"
Offline
Pages: 1