diff options
Diffstat (limited to 'bin/statusbar')
| -rwxr-xr-x | bin/statusbar | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/bin/statusbar b/bin/statusbar new file mode 100755 index 0000000..aead5aa --- /dev/null +++ b/bin/statusbar @@ -0,0 +1,52 @@ +#!/bin/sh + +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>" +} + +network() { + 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>" +} + +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>" +} + +clock() { + 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 +done |
