-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-status
executable file
·44 lines (36 loc) · 950 Bytes
/
wp-status
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#! /usr/bin/env bash
source bszi3b-shared.bash &> /dev/null || source ${0%/*}/bszi3b-shared.bash || exit 1
DEVICE=${DEVICE:-"@DEFAULT_AUDIO_SINK@"}
ICON_LO=${ICON_LO:-"< "}
ICON_MID=${ICON_MID:-"<l "}
ICON_HI=${ICON_HI:-"<ll "}
ICON_MUTE=${ICON_MUTE:-"<X "}
case "$BLOCK_BUTTON" in
1) wpctl set-mute $DEVICE toggle ;;
3) wpctl set-volume $DEVICE 1.0 ;;
4) wpctl set-volume $DEVICE 0.05+ ;;
5) wpctl set-volume $DEVICE 0.05- ;;
esac
volume=$(wpctl get-volume $DEVICE)
[ -z "$volume" ] && i3berr "WPCTL Error"
volume=${volume##*:}
muted=${volume##* }
volume=${volume%%\[MUTED\]}
if [ "$muted" == "[MUTED]" ]; then
icon=$ICON_MUTE
COLOR=$COLOR_ALT
else
main=${volume%.*}
sub=${volume#*.}
if (( $main < 1 )); then
icon=$ICON_LO
COLOR=$COLOR_LO
elif (( $main >= 1 )) && (( $sub >= 1 )); then
icon=$ICON_HI
COLOR=$COLOR_HI
else
icon=$ICON_MID
fi
fi
LONG=$icon$volume
i3bprint