remove pamixer dependency

This commit is contained in:
Alexander Bocken 2023-10-12 18:01:00 +02:00
parent 73fcf5a72b
commit 01e7f20b2e
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8
2 changed files with 30 additions and 43 deletions

View File

@ -9,8 +9,8 @@ xrdb -merge ~/.config/x11/Xresources
setbg & # set the background with the `setbg` script setbg & # set the background with the `setbg` script
xrdb ${XDG_CONFIG_HOME:-$HOME/.config}/x11/xresources & xrdbpid=$! # Uncomment to use Xresources colors/settings on startup xrdb ${XDG_CONFIG_HOME:-$HOME/.config}/x11/xresources & xrdbpid=$! # Uncomment to use Xresources colors/settings on startup
autostart="picom mpd dunst unclutter dwmblocks update_musicbar pipewire remapd"
autostart="picom mpd dunst unclutter dwmblocks update_musicbar pipewire remapd pipewire"
for program in $autostart; do for program in $autostart; do
pidof -s "$program" || setsid -f "$program" pidof -s "$program" || setsid -f "$program"
done >/dev/null 2>&1 done >/dev/null 2>&1

View File

@ -1,52 +1,39 @@
#!/bin/sh #!/bin/sh
# Prints the current volume or 🔇 if muted. Uses PulseAudio by default, # Prints the current volume or 🔇 if muted.
# uncomment the ALSA lines if you remove PulseAudio.
case $BLOCK_BUTTON in case $BLOCK_BUTTON in
# 1) setsid "$TERMINAL" -e alsamixer & ;; 1) setsid -w -f "$TERMINAL" -e pulsemixer; pkill -RTMIN+10 "${STATUSBAR:-dwmblocks}" ;;
# 2) amixer sset Master toggle ;; 2) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;;
# 4) amixer sset Master 5%+ >/dev/null 2>/dev/null ;; 4) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+ ;;
# 5) amixer sset Master 5%- >/dev/null 2>/dev/null ;; 5) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%- ;;
1) setsid "$TERMINAL" -e pulsemixer & ;;
2) pamixer -t ;;
4) pamixer --allow-boost -i 1 ;;
5) pamixer --allow-boost -d 1 ;;
3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted. 3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted.
- Middle click to mute. - Middle click to mute.
- Scroll to change." - Scroll to change." ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac esac
#volstat="$(pactl list sinks)" vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
## volstat="$(amixer get Master)" # ALSA only equivalent.
#
## Uses active sink if one is running, otherwise just go for the default one (First one listed in pactl list sinks)
#if [ -z "$(echo "$volstat" | grep -A10 'State: RUNNING' )" ]; then
# echo "$volstat" | grep -q "Mute: yes" && printf "🔇\\n" && exit
#else
# echo "$volstat" | grep -A10 "State: RUNNING" | grep -q "Mute: yes" && printf "🔇\\n" && exit
#fi
## echo "$volstat" | grep "\[off\]" >/dev/null && printf "🔇\\n" && exit # ALSA
#
## Uses active sink if one is running, otherwise just go for the default one (First one listed in pactl list sinks)
#if [ -z "$(echo "$volstat" | grep -A10 'State: RUNNING' )" ]; then
# vol="$(echo "$volstat" | grep '[0-9]\+%' | sed "s,.* \([0-9]\+\)%.*,\1,;1q")"
#else
# vol="$(echo "$volstat" | grep -A10 "State: RUNNING" | grep '[0-9]\+%' | sed "s,.* \([0-9]\+\)%.*,\1,;1q")"
#fi
# vol=$(echo "$volstat" | grep -o "\[[0-9]\+%\]" | sed "s/[^0-9]*//g;1q") # ALSA # If muted, print 🔇 and exit.
vol="$(pamixer --get-volume-human | tr -d '%')" [ "$vol" != "${vol%\[MUTED\]}" ] && echo 🔇 && exit
if echo "$vol" | grep -q muted; then
printf '🔇\n'
else vol="${vol#Volume: }"
if [ "$vol" -gt "70" ]; then
icon="🔊" split() {
elif [ "$vol" -lt "30" ]; then # For ommiting the . without calling and external program.
icon="🔈" IFS=$2
else set -- $1
icon="🔉" printf '%s' "$@"
fi }
printf "%s%s%%\\n" "$icon" "$vol"
fi vol="$(printf "%.0f" "$(split "$vol" ".")")"
case 1 in
$((vol >= 70)) ) icon="🔊" ;;
$((vol >= 30)) ) icon="🔉" ;;
$((vol >= 1)) ) icon="🔈" ;;
* ) echo 🔇 && exit ;;
esac
echo "$icon$vol%"