From dd2b49db4b45feb6eed5b73cdf7f3fe5a843550b Mon Sep 17 00:00:00 2001 From: Aargh Rai Date: Sun, 20 Sep 2026 16:38:38 +0530 Subject: xrandr replaced by gammastep for night light --- i3/red-shift.sh | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'i3/red-shift.sh') diff --git a/i3/red-shift.sh b/i3/red-shift.sh index bb847e6..4d311c7 100755 --- a/i3/red-shift.sh +++ b/i3/red-shift.sh @@ -1,31 +1,23 @@ #!/usr/bin/env bash -OUTPUT="eDP-1-1" -STEP=0.1 -STATE="${XDG_RUNTIME_DIR:-/tmp}/xrandr-redshift" +STATE="${XDG_RUNTIME_DIR}/gammastep-temp" +STEP=500 +MIN=1000 +MAX=6500 -if [[ -f "$STATE" ]]; then - GAMMA=$(cat "$STATE") -else - GAMMA=1.0 -fi +current=$(cat "$STATE" 2>/dev/null || echo 6500) case "$1" in - up) - GAMMA=$(awk -v g="$GAMMA" -v s="$STEP" 'BEGIN { - g -= s - if (g < 0.1) g = 0.1 - printf "%.1f", g - }') - ;; down) - GAMMA=$(awk -v g="$GAMMA" -v s="$STEP" 'BEGIN { - g += s - if (g > 1.0) g = 1.0 - printf "%.1f", g - }') + current=$((current + STEP)) + ;; + up) + current=$((current - STEP)) ;; esac -echo "$GAMMA" > "$STATE" -xrandr --output "$OUTPUT" --gamma "1.0:${GAMMA}:${GAMMA}" +current=$(( current < MIN ? MIN : current > MAX ? MAX : current )) + +echo "$current" > "$STATE" +gammastep -m randr -x +gammastep -m randr -O "$current" -- cgit v1.2.3