From 2905efa5aa45fe1d218f1bc068e901b2f89384cd Mon Sep 17 00:00:00 2001 From: koksnuss Date: Wed, 8 Aug 2018 21:23:52 +0200 Subject: [PATCH] add cpu temp suport --- config | 8 +++++++- modules/temp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100755 modules/temp diff --git a/config b/config index bf19d8e..7278da0 100644 --- a/config +++ b/config @@ -31,7 +31,13 @@ instance=ram [cpu] label=☷ -# instance=long +instance=long +interval=2 + +[temp] +label=ϑ +interval=2 +instance=long [ip] # label=ip diff --git a/modules/temp b/modules/temp new file mode 100755 index 0000000..cbbe6ae --- /dev/null +++ b/modules/temp @@ -0,0 +1,52 @@ +#!/bin/bash + +[[ "$BLOCK_INSTANCE" =~ "long" || "$BLOCK_BUTTON" == 1 ]] && LONG=true + +[[ "$BLOCK_BUTTON" == 2 ]] && i3-sensible-terminal -e htop + +sensors *-isa-* | awk -v LONG="$LONG" ' + match($0, /^Package[^\+]*\+([0-9]{1,3})[^\+]*\+([0-9]{1,3})/, matches) { + temp = matches[1] + high = matches[2] + step = high / 8 + tresholdc = 40 + stepc = ( high - tresholdc ) / 6 + } + END { + if (LONG == "true") { + printf("%d°C\n", temp) + printf("%d°C\n", temp) + } else { + if (temp < step) { + printf("▁\n▁\n") + } else if (temp < step * 2 ) { + printf("▂\n▂\n") + } else if (temp < step * 3 ) { + printf("▃\n▃\n") + } else if (temp < step * 4 ) { + printf("▄\n▄\n") + } else if (temp < step * 5 ) { + printf("▅\n▅\n") + } else if (temp < step * 6 ) { + printf("▆\n▆\n") + } else if (temp < step * 7 ) { + printf("▇\n▇\n") + } else { + printf("█\n█\n") + } + } + if (temp < stepc + tresholdc) { + print("#04B431\n") + } else if (temp < stepc * 2 + tresholdc) { + print("#A8FF00\n") + } else if (temp < stepc * 3 + tresholdc) { + print("#FFF600\n") + } else if (temp < stepc * 4 + tresholdc) { + print("#FFAE00\n") + } else if (temp < stepc * 5 + tresholdc) { + print("#FF0000\n") + } else { + exit 33 + } + } +'