From 7c9576dd7650f1958e87d0a7155437fdee134462 Mon Sep 17 00:00:00 2001 From: Sam Nystrom Date: Tue, 11 Apr 2023 20:13:23 -0500 Subject: feat(bin): add statusbar script --- bin/status.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 bin/status.sh (limited to 'bin/status.sh') diff --git a/bin/status.sh b/bin/status.sh new file mode 100755 index 0000000..7ad178e --- /dev/null +++ b/bin/status.sh @@ -0,0 +1,51 @@ +#!/bin/sh -eu + +pulseaudio() { + 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) + ssid= + if [ -n "$ssid" ]; then + symbol="直" + else + symbol="睊" + fi + echo "$symbol $ssid" +} + +brightness() { + 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 "{ print \$$idx }" ) ;; + "Charging" ) symbol=$(echo "         " | awk "{ print \$$idx }" ) ;; + "Full" ) symbol="" ;; + esac + echo "$symbol $capacity%" +} + +clock() { + echo " $(date '+%b %d %H:%M')" +} + +while true; do + sleep 0.2 + somebar -c status "$(pulseaudio) | $(network) | $(brightness) | $(battery) | $(clock)" || true +done -- cgit v1.2.3