summaryrefslogtreecommitdiff
path: root/bin/statusbar
diff options
context:
space:
mode:
authorSam Nystrom <sam@samnystrom.dev>2024-10-15 13:29:10 -0400
committerSam Nystrom <sam@samnystrom.dev>2024-10-15 13:29:10 -0400
commit2c98bbacc8db3b251e1679f9da84cf1f5ed5726a (patch)
tree10d44c9b82d275d66d880ff8ec33992cddda12b5 /bin/statusbar
parentc8c79e6c6a5c4bb1e0ba44f309ce5ae612f97e1c (diff)
update ~/bin
Diffstat (limited to 'bin/statusbar')
-rwxr-xr-xbin/statusbar77
1 files changed, 0 insertions, 77 deletions
diff --git a/bin/statusbar b/bin/statusbar
deleted file mode 100755
index 4dfafec..0000000
--- a/bin/statusbar
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/bin/sh
-
-volume() {
- volume="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
- volume="$(dc -e "${volume#Volume:\ } 100 * p")"
- volume="${volume%.*}"
- if [ "$volume" -eq 0 ]; then
- symbol=
- elif [ "$volume" -le 50 ]; then
- symbol=
- else
- symbol=
- fi
- printf '%s %d%%' "$symbol" "$volume"
-}
-
-network() {
- ssid="$(iwctl station wlan0 get-networks | awk -F' ' '/>/{print $3}')"
- if [ -n "$ssid" ]; then
- printf '󰖩 %s' "$ssid"
- else
- printf '󰖪 '
- fi
-}
-
-brightness() {
- printf ' %d%%' "$(brightctl)"
-}
-
-battery() {
- cap="$(cat /sys/class/power_supply/BAT0/capacity)"
- stat="$(cat /sys/class/power_supply/BAT0/status)"
-
- symbol=󰁹
- index=$(((cap-1)/10+1))
- case "$stat" in
- Discharging)
- symbol="$(printf '󰂃 󰁻 󰁼 󰁽 󰁾 󰁿 󰂀 󰂁 󰂂 󰁹' | cut -d' ' -f$index)"
- ;;
- Charging)
- symbol="$(printf '󰢜 󰂆 󰂇 󰂈 󰢝 󰂉 󰢞 󰂊 󰂋 󰂅' | cut -d' ' -f$index)"
- ;;
- Full)
- symbol=󰂄
- ;;
- esac
- printf '%s %d%%' "$symbol" "$cap"
-}
-
-clock() {
- printf ' %s' "$(date '+%b %-d %H:%M:%S')"
-}
-
-# Make the volume and brightness sections appear to update more often by
-# heuristically detecting when the user is changing them.
-last_vol=
-last_brt=
-sleep_for=1
-while true; do
- vol="$(volume)"
- brt="$(brightness)"
- if [ "$last_vol" != "$vol" ] || [ "$last_brt" != "$brt" ]; then
- sleep_for=0.1
- elif [ ${sleep_for%%.*} != 1 ]; then
- sleep_for=$((sleep_for+0.1))
- else
- sleep_for=1
- fi
-
- printf '%s | %s | %s | %s | %s\n' \
- "$vol" \
- "$(network)" \
- "$brt" \
- "$(battery)" \
- "$(clock)"
- sleep $sleep_for
-done