summaryrefslogtreecommitdiff
path: root/.local/bin/statusbar/cpuinfo
diff options
context:
space:
mode:
author0scar <qgt268@alumni.ku.dk>2021-06-10 08:15:24 +0000
committer0scar <qgt268@alumni.ku.dk>2021-06-10 08:15:24 +0000
commit2ee4672b82bddf7e78aff7a2ef212f495debadac (patch)
tree9ce6557e5cd666dddbb4e26c377c75451cc0df6f /.local/bin/statusbar/cpuinfo
parentcd9049c5033f2c403bfdae1e997790d67523d1ba (diff)
Update statusbar scripts
Diffstat (limited to '.local/bin/statusbar/cpuinfo')
-rwxr-xr-x.local/bin/statusbar/cpuinfo56
1 files changed, 32 insertions, 24 deletions
diff --git a/.local/bin/statusbar/cpuinfo b/.local/bin/statusbar/cpuinfo
index f46121b..de53f22 100755
--- a/.local/bin/statusbar/cpuinfo
+++ b/.local/bin/statusbar/cpuinfo
@@ -1,30 +1,38 @@
-#!/usr/bin/env sh
+#!/usr/bin/env bash
set -e
-case $BLOCK_BUTTON in
- 1) notify-send --urgency=low \
- "Process status" \
- "$(ps -eo pid,pcpu,size,comm \
- | sort -rnk 3 \
- | awk '{printf "% 8s% 8s% 8s ", $1, $2, $3;
- $1="";$2="";$3="";
- print $0; c++}
- c>10 {exit}')"
- ;;
- 3) notify-send --urgency=low \
- "Process status" \
- "$(ps -eo pid,pcpu,size,cmd \
- | sort -rnk 3 \
- | cut -b -45 \
- | awk '{printf "% 8s% 8s% 8s ", $1, $2, $3;
- $1="";$2="";$3="";
- print $0; c++}
- c>10 {exit}')"
- ;;
+ARG=${1:-$BLOCK_BUTTON}
+
+case $ARG in
+ 1) notify-send --urgency=low \
+ "Process status" \
+ "$(ps -eo pid,pcpu,size,comm \
+ | sort -rnk 3 \
+ | awk '{printf "% 8s% 8s% 8s ", $1, $2, $3;
+ $1="";$2="";$3="";
+ print $0; c++}
+ c>10 {exit}')"
+ ;;
+ 3) notify-send --urgency=low \
+ "Process status" \
+ "$(ps -eo pid,pcpu,size,cmd \
+ | sort -rnk 3 \
+ | cut -b -45 \
+ | awk '{printf "% 8s% 8s% 8s ", $1, $2, $3;
+ $1="";$2="";$3="";
+ print $0; c++}
+ c>10 {exit}')"
+ ;;
esac
+# Thermals
+# "Never cat something into awk", yeah, but it won't function properly if it
+# encounters a missing `/temp`-file.
+TEMP=$(cat /sys/class/thermal/thermal_zone*/temp 2>/dev/null | awk '{s+=$1}END{printf "%.1f", s / (1000*NR)}' )
+TEMP=`(( $(echo "$TEMP > 45" | bc -l) )) && echo -en "\x0c${TEMP}\x0b" || echo -en "$TEMP"`
+
# Load
-sed -Ee 's/^([0-9]+\.[0-9]+) .*/[\1  /g' /proc/loadavg | tr -d '\n'
+LOAD=$(sed -Ee 's/^([0-9]+\.[0-9]+) .*/\1/g' /proc/loadavg | tr -d '\n')
-# Thermals
-awk '{s+=$1}END{printf "%.1f°]", s / (1000*NR)}' /sys/class/thermal/thermal_zone*/temp
+
+echo -en "[${LOAD} \x0f\x0b ${TEMP}°]"