From 63303977071f34d8142709960e8dae97cea1951e Mon Sep 17 00:00:00 2001 From: jao Date: Tue, 9 Aug 2022 23:48:44 +0100 Subject: examples -> etc --- etc/status.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 etc/status.sh (limited to 'etc/status.sh') diff --git a/etc/status.sh b/etc/status.sh new file mode 100755 index 0000000..151728b --- /dev/null +++ b/etc/status.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +STATUSPIPE="/tmp/xmobar_status_jrk" + +function isMuted () { + # retrieve mute status + # return an arbitrary string for true or nothing at all + echo +} + +function getPercent () { + # somehow retrieve the percent value as plain int (e.g. "66") + echo "66" +} + +function percentBar () { + local i=1 res= + normal=47 high=80 + fgColor='#657b83' mutedColor='#cb4b16' + lowColor='#859900' midColor='#b58900' + highColor='#cb4b16' + + bar="$(echo -ne "\u2588")" + percent="$( getPercent )" + muted="$( isMuted )" + + if [ -n "$muted" ]; then + res="" + else + res="" + fi + + while [ $i -lt $percent ]; do + if [ $i -eq $normal -a -z "$muted" ]; then + res+="" + elif [ $i -eq $high -a -z "$muted" ]; then + res+="" + fi + + res+=$bar + i=$((i+1)) + done + + res+="" + + while [ $i -lt 100 ]; do + res+='-' + i=$((i+1)) + done + + echo "$res" +} + +[[ -p $STATUSPIPE ]] || mkfifo $STATUSPIPE + +echo "$( percentBar )" > "$STATUSPIPE" -- cgit v1.2.3