dotfiles

Alpine Linux dotfiles

git clone git://git.lin.moe/dotfiles.git

 1#!/bin/sh
 2
 3VOLUME_MUTE="🔇"
 4VOLUME_LOW="🔈"
 5VOLUME_MID="🔉"
 6VOLUME_HIGH="🔊"
 7
 8SOUND_LEVEL=$(pactl get-sink-volume @DEFAULT_SINK@ | grep '^Volume:' | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,')
 9#MUTED=$(amixer get Master | awk ' /%/{print ($NF=="[off]" ? 1 : 0); exit;}')
10MUTED=$(pactl get-sink-mute @DEFAULT_SINK@)
11
12ICON=$VOLUME_MUTE
13if [[ "$MUTED" == *" yes" ]]
14then
15    ICON="$VOLUME_MUTE"
16else
17    if [ "$SOUND_LEVEL" -lt 34 ]
18    then
19        ICON="$VOLUME_LOW"
20    elif [ "$SOUND_LEVEL" -lt 67 ]
21    then
22        ICON="$VOLUME_MID"
23    else
24        ICON="$VOLUME_HIGH"
25    fi
26fi
27
28echo "$ICON" "$SOUND_LEVEL" | awk '{ printf(" %s%3s%% \n", $1, $2) }'