diff options
| author | Sam Nystrom <sam@samnystrom.dev> | 2023-04-26 17:47:27 -0400 |
|---|---|---|
| committer | Sam Nystrom <sam@samnystrom.dev> | 2023-04-26 17:47:27 -0400 |
| commit | 879c8933b0b78e7dc84494db2da41c474904be88 (patch) | |
| tree | 60874075f317d91570bbde1075e4a505c033bf94 | |
| parent | cee0b6bf86d3829d85838f20b3092c5f762b7fe8 (diff) | |
style: format statusbar with shfmt
| -rwxr-xr-x | bin/statusbar | 69 |
1 files changed, 38 insertions, 31 deletions
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 "<span foreground=\"#ed8796\">$volume_symbol $volume%</span>" + 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 "<span foreground=\"#ed8796\">$volume_symbol $volume%</span>" } network() { - ssid=$(iwgetid -r) - if [ -n "$ssid" ]; then - symbol="直" - else - symbol="睊" - fi - echo "<span foreground=\"#f5a97f\">$symbol $ssid</span>" + ssid=$(iwgetid -r) + if [ -n "$ssid" ]; then + symbol="直" + else + symbol="睊" + fi + echo "<span foreground=\"#f5a97f\">$symbol $ssid</span>" } brightness() { - echo "<span foreground=\"#eed49f\"> $(brightnessctl -m | awk -F, '{ print $4 }')</span>" + echo "<span foreground=\"#eed49f\"> $(brightnessctl -m | awk -F, '{ print $4 }')</span>" } 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 "<span foreground=\"#ed8796\"></span>,,,,,,,,," | awk -F, "{ print \$$idx }" ) ;; - "Charging" ) symbol=$(echo " " | awk "{ print \$$idx }" ) ;; - "Full" ) symbol="" ;; - esac - echo "<span foreground=\"#a6da95\">$symbol $capacity%</span>" + 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 "<span foreground=\"#ed8796\"></span>,,,,,,,,," | + awk -F, "{ print \$$idx }") + ;; + "Charging") + symbol=$(echo " " | awk "{ print \$$idx }") + ;; + "Full") + symbol="" + ;; + esac + echo "<span foreground=\"#a6da95\">$symbol $capacity%</span>" } clock() { - echo "<span foreground=\"#7dc4e4\"> $(date '+%b %d %H:%M')</span>" + echo "<span foreground=\"#7dc4e4\"> $(date '+%b %d %H:%M')</span>" } 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 |
