diff options
Diffstat (limited to 'i3')
| -rwxr-xr-x | i3/red-shift.sh | 36 |
1 files changed, 14 insertions, 22 deletions
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" |
