From 8bcdc9b10495dd3d8be425a971ffd5a191d31e35 Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Thu, 28 Jan 2021 21:54:30 -0500 Subject: [PATCH] Audio-set: Add script. Volume change script for WM Instead of calling pactl or amixer directly, you can use this script. The advantage is that this script checks whether the sound is muted, and unmutes it for you when you change the volume, more closely mimicking the behavior of most desktop environments. It also sends a notification with the current audio status. This implementation relies on amixer and pulseaudio, although could easily work with an alsa-only setup if that's your thing, just by replacing the pactl commands with amixer (or any other alsa mixer) commands. --- audio-set | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 audio-set diff --git a/audio-set b/audio-set new file mode 100755 index 0000000..572bdf5 --- /dev/null +++ b/audio-set @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# When changing volume, if muted, unmute + +if [[ ${1} ]]; then + [[ $(amixer sget Master | tail -n 1 | grep "off") ]] && + pactl set-sink-mute 0 toggle + pactl set-sink-volume 0 ${1}% +else + pactl set-sink-mute 0 toggle +fi + +notify-send "Volume" "$(amixer sget Master | tail -n 1)" -t 1000 -- 2.39.2