From 879c8933b0b78e7dc84494db2da41c474904be88 Mon Sep 17 00:00:00 2001 From: Sam Nystrom Date: Wed, 26 Apr 2023 17:47:27 -0400 Subject: style: format statusbar with shfmt --- bin/statusbar | 69 ++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 31 deletions(-) (limited to 'bin') diff --git a/bin/statusbar b/bin/statusbar index aead5aa..d43cb0c 100755 --- a/bin/statusbar +++ b/bin/statusbar @@ -3,50 +3,57 @@ set -eu volume() { - volume=$(pactl get-sink-volume @DEFAULT_SINK@ \ - | awk 'match($0, /\d+%/) { print substr($0, RSTART, RLENGTH-1) }') - if [ "$volume" -eq 0 ]; then - volume_symbol="" - elif [ "$volume" -le 50 ]; then - volume_symbol="" - else - volume_symbol="" - fi - echo "$volume_symbol $volume%" + volume=$(pactl get-sink-volume @DEFAULT_SINK@ | + awk 'match($0, /\d+%/) { print substr($0, RSTART, RLENGTH-1) }') + if [ "$volume" -eq 0 ]; then + volume_symbol="" + elif [ "$volume" -le 50 ]; then + volume_symbol="" + else + volume_symbol="" + fi + echo "$volume_symbol $volume%" } network() { - ssid=$(iwgetid -r) - if [ -n "$ssid" ]; then - symbol="直" - else - symbol="睊" - fi - echo "$symbol $ssid" + ssid=$(iwgetid -r) + if [ -n "$ssid" ]; then + symbol="直" + else + symbol="睊" + fi + echo "$symbol $ssid" } brightness() { - echo " $(brightnessctl -m | awk -F, '{ print $4 }')" + echo " $(brightnessctl -m | awk -F, '{ print $4 }')" } battery() { - status=$(cat /sys/class/power_supply/BAT0/status) - capacity=$(cat /sys/class/power_supply/BAT0/capacity) - - idx=$(( ($capacity - 1) / 10 )) - case "$status" in - "Discharging") symbol=$(echo "󰂃,,,,,,,,," | awk -F, "{ print \$$idx }" ) ;; - "Charging" ) symbol=$(echo "         " | awk "{ print \$$idx }" ) ;; - "Full" ) symbol="" ;; - esac - echo "$symbol $capacity%" + status=$(cat /sys/class/power_supply/BAT0/status) + capacity=$(cat /sys/class/power_supply/BAT0/capacity) + + idx=$(((capacity - 1) / 10)) + case "$status" in + "Discharging") + symbol=$(echo "󰂃,,,,,,,,," | + awk -F, "{ print \$$idx }") + ;; + "Charging") + symbol=$(echo "         " | awk "{ print \$$idx }") + ;; + "Full") + symbol="" + ;; + esac + echo "$symbol $capacity%" } clock() { - echo " $(date '+%b %d %H:%M')" + echo " $(date '+%b %d %H:%M')" } while true; do - somebar -c status "$(volume) | $(network) | $(brightness) | $(battery) | $(clock)" || true - sleep 0.2 + somebar -c status "$(volume) | $(network) | $(brightness) | $(battery) | $(clock)" || true + sleep 0.2 done -- cgit v1.2.3