dotfiles/home/bin/executable_get-volume.sh
2023-03-04 17:45:19 +08:00

14 lines
356 B
Bash

#!/bin/bash
muted=$(pactl get-sink-mute @DEFAULT_SINK@ | awk -F ' ' '{print $2}')
if [ $muted == "yes" ]; then
echo "{\"alt\": \"mute\", \"class\": \"muted\", \"tooltip\": \"muted\"}"
exit
fi
VOL=$(pactl get-sink-volume @DEFAULT_SINK@ | grep Volume | awk -F' ' '{print $5}' | sed -e 's/%$//')
echo "{\"percentage\": $VOL, \"tooltip\": \"$VOL%\"}"