From 4d1991fdde86152510327a32e033f14163b82302 Mon Sep 17 00:00:00 2001 From: johannst Date: Wed, 20 Nov 2019 21:39:30 +0100 Subject: added redshift i3blocks entry + script to control --- scripts/redshift.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 scripts/redshift.sh (limited to 'scripts') diff --git a/scripts/redshift.sh b/scripts/redshift.sh new file mode 100755 index 0000000..0ef6e34 --- /dev/null +++ b/scripts/redshift.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# dotfiles -- scripts/redshift.sh +# author: johannst + +# Didn't find a way to query current temperature. +# Use a file to keep track +VALUE_FILE=~/.redshift + +function setRedshift() { + # 6500K default temp + local val=${1:-6500} + echo "$val" > $VALUE_FILE + redshift -P -O $val &> /dev/null +} + +[[ ! -f $VALUE_FILE ]] && setRedshiftFile + +curr_val=$(<$VALUE_FILE) +case $BLOCK_BUTTON in + 3) setRedshift ;; # right click, set default + 4) setRedshift $((curr_val + 200)); ;; # scroll up, inc temp (more blue) + 5) setRedshift $((curr_val - 200)); ;; # scroll down, dec temp (more red) +esac + + +new_val=$(<$VALUE_FILE) +# format protocol (https://github.com/vivien/i3blocks/tree/master/docs#format) +echo ${new_val}K +echo "" +if [ $new_val -lt 5000 ]; then + echo "#eba02f" +elif [ $new_val -gt 7500 ]; then + echo "#42adff" +fi + -- cgit v1.2.3