summaryrefslogtreecommitdiff
path: root/shell-scripts/spectrwmbar
diff options
context:
space:
mode:
Diffstat (limited to 'shell-scripts/spectrwmbar')
-rw-r--r--shell-scripts/spectrwmbar59
1 files changed, 0 insertions, 59 deletions
diff --git a/shell-scripts/spectrwmbar b/shell-scripts/spectrwmbar
deleted file mode 100644
index a106b01..0000000
--- a/shell-scripts/spectrwmbar
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/env sh
-# script for spectrwm status bar
-
-trap 'update' 5
-
-fgcolors=("+@fg=1;" "+@fg=2;" "+@fg=3;" "+@fg=4;" "+@fg=5;" "+@fg=6;" "+@fg=7;" "+@fg=8;")
-nfgcolors=${#fgcolors[@]}
-
-SLEEP_SEC=5m
-
-repeat() {
- i=0; while [ $i -lt $1 ]
- do
- echo -ne "$TOKEN"
- i=$(( i + 1 ))
- done
-}
-
-cpu() {
- read cpu a b c previdle rest < /proc/stat
- prevtotal=$((a+b+c+previdle))
- sleep 0.5
- read cpu a b c idle rest < /proc/stat
- total=$((a+b+c+idle))
- cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) ))
- echo -e "CPU: $cpu%"
-}
-
-battery() {
- BATTERY="$(cat /sys/class/power_supply/BAT0/capacity)"
-
- BAR_LEFT=$BATTERY
- BATTERY_BAR=""
- BLOCK=$(( 100 / nfgcolors ))
- TOKEN=$(printf '\u2588')
-
- BAT_COL=$(( $nfgcolors -1 ))
- #loops forever outputting a line every SLEEP_SEC secs
- while [ $(( BAR_LEFT - BLOCK )) -gt 0 ]
- do
- BATTERY_BAR="${fgcolors[$BAT_COL]}$(repeat $BLOCK)${BATTERY_BAR}"
- BAR_LEFT=$(( BAR_LEFT - BLOCK ))
- BAT_COL=$(( BAT_COL - 1))
- done
-
- BATTERY_BAR="BATTERY: ${fgcolors[$BAT_COL]}$(repeat $BAR_LEFT)${BATTERY_BAR}"
- echo $BATTERY_BAR
-}
-
-update() {
- echo "$(cpu) $(battery)"
- wait
-}
-
-while :; do
- update
- sleep $SLEEP_SEC &
- wait
-done