sway_volume: improve notifications
This commit is contained in:
parent
afdb292741
commit
90c0e2c903
1 changed files with 25 additions and 2 deletions
|
@ -2,8 +2,23 @@
|
|||
source $HOME/.config/sway/bin/sway_helpers
|
||||
SINK=$(pactl info | grep "Default Sink" | cut -d ' ' -f 3)
|
||||
ICON_PATH=$HOME/.local/share/icons/Tela-circle-dark/16/actions
|
||||
NOTIFY_APP="dunstify -a \"Volume\" -r 97"
|
||||
NOTIFY_APP="dunstify -a \"Volume\" -h string:x-dunst-stack-tag:volume"
|
||||
|
||||
function getProgressString() {
|
||||
ITEMS="$1" # The total number of items(the width of the bar)
|
||||
FILLED_ITEM="$2" # The look of a filled item
|
||||
NOT_FILLED_ITEM="$3" # The look of a not filled item
|
||||
STATUS="$4" # The current progress status in percent
|
||||
|
||||
# calculate how many items need to be filled and not filled
|
||||
FILLED_ITEMS=$(echo "((${ITEMS} * ${STATUS})/100 + 0.5) / 1" | bc)
|
||||
NOT_FILLED_ITEMS=$(echo "$ITEMS - $FILLED_ITEMS" | bc)
|
||||
|
||||
# Assemble the bar string
|
||||
msg=$(printf "%${FILLED_ITEMS}s" | sed "s| |${FILLED_ITEM}|g")
|
||||
msg=${msg}$(printf "%${NOT_FILLED_ITEMS}s" | sed "s| |${NOT_FILLED_ITEM}|g")
|
||||
echo "$msg"
|
||||
}
|
||||
function notify() {
|
||||
VOLUME=$(pactl list sinks | grep "Name: $SINK" -A 8 | grep -oE '[0-9]*%' | head -n 1 | sed 's/%//')
|
||||
MUTE=$(pactl list sinks | grep "Name: $SINK" -A 8 | grep 'Mute:' | cut -d " " -f 2)
|
||||
|
@ -11,16 +26,24 @@ function notify() {
|
|||
echo $MUTE
|
||||
|
||||
ICON=""
|
||||
TITLE=""
|
||||
M=""
|
||||
if [ "$MUTE" = "yes" ]; then
|
||||
ICON=$ICON_PATH/audio-volume-muted.svg
|
||||
TITLE="Volume ${VOLUME}%"
|
||||
M=""
|
||||
elif [ $VOLUME -le 33 ]; then
|
||||
ICON=$ICON_PATH/audio-volume-low.svg
|
||||
TITLE="Volume ${VOLUME}%"
|
||||
elif [ $VOLUME -le 67 ]; then
|
||||
ICON=$ICON_PATH/audio-volume-medium.svg
|
||||
TITLE="Volume ${VOLUME}%"
|
||||
else
|
||||
ICON=$ICON_PATH/audio-volume-high.svg
|
||||
TITLE="Volume ${VOLUME}%"
|
||||
fi
|
||||
$NOTIFY_APP -i $ICON -a "Volume" "$VOLUME Mute: $MUTE"
|
||||
# $NOTIFY_APP -i $ICON -a "Volume" "$TEXT"
|
||||
$NOTIFY_APP -i $ICON -a "$TITLE" "[$(getProgressString 15 "$M" " " $VOLUME)]"
|
||||
}
|
||||
|
||||
APP="pavucontrol"
|
||||
|
|
Loading…
Reference in a new issue