summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjohannst <johannes.stoelp@gmail.com>2019-11-20 21:39:30 +0100
committerjohannst <johannes.stoelp@gmail.com>2019-11-20 21:39:30 +0100
commit4d1991fdde86152510327a32e033f14163b82302 (patch)
tree0dd15b4d7f09efa92ecbb1c8f6328bfecaeb9a44
parent8f851bbc4a4ed86aa2f768fe779130c4d2ade11f (diff)
downloaddotfiles-4d1991fdde86152510327a32e033f14163b82302.tar.gz
dotfiles-4d1991fdde86152510327a32e033f14163b82302.zip
added redshift i3blocks entry + script to control
-rw-r--r--i3blocks.conf15
-rwxr-xr-xscripts/redshift.sh35
2 files changed, 48 insertions, 2 deletions
diff --git a/i3blocks.conf b/i3blocks.conf
index 5e0e77c..d0f66e5 100644
--- a/i3blocks.conf
+++ b/i3blocks.conf
@@ -30,20 +30,31 @@
command=/usr/lib/i3blocks/$BLOCK_NAME
markup=none
separator_block_width=7
-separator=false
+separator=true
border_top=0
border_left=0
border_right=0
border_bottom=2
#
+# Misc
+#
+
+[redshift]
+command=$HOME/.scripts/redshift.sh
+label=🌡️
+interval=once
+border=#a8a8a8
+
+#
# Network
#
[vpn]
command=echo "$(expressvpn status | head -n1 | sed 's/\x1b\[[0-9;]*m//g')"
-label=VPN
+label=
interval=30
+border=#000000
[eth]
command=$HOME/.scripts/eth.sh
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
+