diff options
Diffstat (limited to '.local/bin/statusbar/sb-microphone')
-rwxr-xr-x | .local/bin/statusbar/sb-microphone | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/.local/bin/statusbar/sb-microphone b/.local/bin/statusbar/sb-microphone new file mode 100755 index 0000000..e07e0de --- /dev/null +++ b/.local/bin/statusbar/sb-microphone @@ -0,0 +1,24 @@ +#!/bin/sh + +mic="$(wpctl get-volume @DEFAULT_SOURCE@)" + +# If muted, print 🔇 and exit. +[ "$mic" != "${mic%\[MUTED\]}" ] && echo && exit + +mic="${mic#Volume: }" + +split() { + # For ommiting the . without calling and external program. + IFS=$2 + set -- $1 + printf '%s' "$@" +} + +mic="$(printf "%.0f" "$(split "$mic" ".")")" + +case 1 in + $((mic >= 1)) ) icon="🎙️" ;; + * ) echo && exit ;; +esac + +echo "$icon $mic%" |