From a63216cc145fb5587d410dc707ed9a1afa75b23d Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Fri, 6 Sep 2024 09:39:25 +0200 Subject: Add key bindings to change external monitor brightness --- yoga/bin/night-light | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100755 yoga/bin/night-light (limited to 'yoga/bin/night-light') diff --git a/yoga/bin/night-light b/yoga/bin/night-light deleted file mode 100755 index b76054d..0000000 --- a/yoga/bin/night-light +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# Usage: night-light [increase|decrease|day|night] -set -e - -TMPFILE=/tmp/.night-light-index - -# https://askubuntu.com/a/1061304 -STEPS=( - "1:0.18172716:0.00000001" - "1:0.42322816:0.00000001" - "1:0.54360078:0.08679949" - "1:0.64373109:0.28819679" - "1:0.71976951:0.42860152" - "1:0.77987699:0.54642268" - "1:0.82854786:0.64816570" - "1:0.86860704:0.73688797" - "1:0.90198230:0.81465502" - "1:0.93853986:0.88130458" - "1:0.97107439:0.94305985" - "1:1:1" -) - -CUR=$((${#STEPS[@]}-1)) -if [ -f $TMPFILE ]; then - CUR=$(cat $TMPFILE) -fi - -case "$1" in - increase) NEW=$(($CUR >= ${#STEPS[@]} ? $CUR : $CUR+1)) ;; - decrease) NEW=$(($CUR <= 0 ? $CUR : $CUR-1)) ;; - day) NEW=$((${#STEPS[@]}-1)) ;; - night) NEW=0 ;; - *) - echo "Invalid argument '$1'" - exit 1 - ;; -esac - -echo $NEW > $TMPFILE - -for MONITOR in $(xrandr --listactivemonitors | tail -n +2 | cut -d'+' -f2 | cut -d' ' -f1 | sed 's/^\*//'); do - BRIGHTNESS=$(xrandr --verbose | grep "^$MONITOR" -A5 | grep Brightness | cut -d':' -f2 | sed 's/\s*//') - xrandr --output $MONITOR --gamma ${STEPS[$NEW]} --brightness $BRIGHTNESS || true -done -- cgit v1.2.3