From 418f7d5c541f82ee495688801b915f0f53be920f Mon Sep 17 00:00:00 2001 From: frosty Date: Sun, 19 May 2024 05:38:51 -0400 Subject: [PATCH] change variable names inside sb scripts, and add uptime --- bin/.local/bin/statusbar/sb-battery | 4 ++-- bin/.local/bin/statusbar/sb-date | 4 ++-- bin/.local/bin/statusbar/sb-memory | 4 ++-- bin/.local/bin/statusbar/sb-uptime | 5 +++++ bin/.local/bin/statusbar/sb-volume | 18 +++++++++--------- 5 files changed, 20 insertions(+), 15 deletions(-) create mode 100755 bin/.local/bin/statusbar/sb-uptime diff --git a/bin/.local/bin/statusbar/sb-battery b/bin/.local/bin/statusbar/sb-battery index 83394da..ef229cf 100755 --- a/bin/.local/bin/statusbar/sb-battery +++ b/bin/.local/bin/statusbar/sb-battery @@ -1,5 +1,5 @@ #!/bin/sh -read -r capacity < /sys/class/power_supply/BAT1/capacity +read -r value < /sys/class/power_supply/BAT1/capacity -printf '[BAT %s%%]\n' "$capacity" +printf '[BAT %s%%]\n' "$value" diff --git a/bin/.local/bin/statusbar/sb-date b/bin/.local/bin/statusbar/sb-date index 4dd2188..8a29a2c 100755 --- a/bin/.local/bin/statusbar/sb-date +++ b/bin/.local/bin/statusbar/sb-date @@ -1,5 +1,5 @@ #!/bin/sh -_date=$(date '+%b %-d %Y %-I:%M %p') +value=$(date '+%b %-d %Y %-I:%M %p') -printf '[%s]\n' "$_date" +printf '[%s]\n' "$value" diff --git a/bin/.local/bin/statusbar/sb-memory b/bin/.local/bin/statusbar/sb-memory index 4b6b428..79f0b8a 100755 --- a/bin/.local/bin/statusbar/sb-memory +++ b/bin/.local/bin/statusbar/sb-memory @@ -1,5 +1,5 @@ #!/bin/sh -memory=$(free -h | awk '/Mem/ {printf "%s/%s\n", $3, $2}' | sed 's/Gi/G/g; s/Mi/M/g') +value=$(free -h | awk '/Mem/ {printf "%s/%s\n", $3, $2}' | sed 's/Gi/G/g; s/Mi/M/g') -printf '[MEM %s]\n' "$memory" +printf '[MEM %s]\n' "$value" diff --git a/bin/.local/bin/statusbar/sb-uptime b/bin/.local/bin/statusbar/sb-uptime new file mode 100755 index 0000000..5e55c0d --- /dev/null +++ b/bin/.local/bin/statusbar/sb-uptime @@ -0,0 +1,5 @@ +#!/bin/sh + +value=$(uptime -p | sed 's/ day[s]*\b/d/g; s/ hour[s]*\b/h/g; s/ minute[s]*\b/m/g; s/up //; s/,//g') + +printf '[%s]\n' "$value" diff --git a/bin/.local/bin/statusbar/sb-volume b/bin/.local/bin/statusbar/sb-volume index e4d6428..52228d6 100755 --- a/bin/.local/bin/statusbar/sb-volume +++ b/bin/.local/bin/statusbar/sb-volume @@ -1,21 +1,21 @@ #!/bin/sh -volume=$(wpctl get-volume @DEFAULT_AUDIO_SINK@) -volume=${volume##Volume: } -volume=${volume%%.*}${volume##*.} +value=$(wpctl get-volume @DEFAULT_AUDIO_SINK@) +value=${value##Volume: } +value=${value%%.*}${value##*.} -case "$volume" in +case "$value" in *MUTED*) muted=1 - volume=${volume%% \[MUTED\]} + value=${value%% \[MUTED\]} ;; esac -volume=${volume#0} -volume=${volume#0} +value=${value#0} +value=${value#0} if [ -z "$muted" ]; then - printf '[VOL %s%%]\n' "$volume" + printf '[VOL %s%%]\n' "$value" else - printf '[VOL %s%% M]\n' "$volume" + printf '[VOL %s%% M]\n' "$value" fi