summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZachIR <zachir@librem.one>2025-08-09 05:56:16 -0500
committerZachIR <zachir@librem.one>2025-08-09 05:56:16 -0500
commitad827fb7c4fd6bdd84be8e8882e63735beca33ce (patch)
treedaaab10f5df58597a0235d7f8789beeac81c4192
parentf5d7a9413cb920be0ff9825b7aba90f56850488e (diff)
Add wpctl for pipewire/wireplumberHEADmaster
-rwxr-xr-xvolsv11
-rw-r--r--volsv.13
2 files changed, 12 insertions, 2 deletions
diff --git a/volsv b/volsv
index e21a2d3..8c377ca 100755
--- a/volsv
+++ b/volsv
@@ -2,7 +2,9 @@
#{{{ detect
detect () {
- if pgrep -x pulseaudio >/dev/null; then
+ if pgrep -x wireplumber >/dev/null; then
+ AUDIO_SERVER="WP"
+ elif pgrep -x pulseaudio >/dev/null; then
AUDIO_SERVER="PULSE"
elif pgrep -x pipewire >/dev/null; then
AUDIO_SERVER="PW"
@@ -17,6 +19,7 @@ detect () {
#{{{ up
up () {
case "$AUDIO_SERVER" in
+ WP) wpctl set-volume @DEFAULT_AUDIO_SINK@ "${amt}%+" ;;
SNDIO) sndioctl output.level=+"$(printf "%0.02f" "$(( amt * 0.01 ))")" ;;
PULSE|PW) pactl set-sink-volume $(pactl get-default-sink) "+${amt}%" ;;
ALSA) amixer sset Master "${amt}%+" ;;
@@ -27,6 +30,7 @@ up () {
#{{{ down
down () {
case "$AUDIO_SERVER" in
+ WP) wpctl set-volume @DEFAULT_AUDIO_SINK@ "${amt}%-" ;;
SNDIO) sndioctl output.level=-"$(printf "%0.02f" "$(( amt * 0.01 ))")" ;;
PULSE|PW) pactl set-sink-volume $(pactl get-default-sink) "-${amt}%" ;;
ALSA) amixer sset Master "${amt}%-" ;;
@@ -39,6 +43,7 @@ mute () {
case "$1" in
spr)
case "$AUDIO_SERVER" in
+ WP) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;;
SNDIO) sndioctl output.mute=! ;;
PULSE|PW) pactl set-sink-mute $(pactl get-default-sink) toggle ;;
ALSA) amixer sset Master toggle ;;
@@ -46,6 +51,7 @@ mute () {
;;
mic)
case "$AUDIO_SERVER" in
+ WP) wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle ;;
SNDIO) sndioctl input.mute=! ;;
PULSE|PW) pactl set-source-mute $(pactl get-default-source) toggle ;;
ALSA) amixer sset Capture toggle ;;
@@ -60,6 +66,7 @@ get () {
case "$1" in
volu)
case "$AUDIO_SERVER" in
+ WP) wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print $2 * 100 "%"}' ;;
SNDIO) printf "%s%%" "$(sndioctl output.level | rev | cut -d'.' -f1 | rev | cut -c 1,2)" ;;
PULSE|PW) pactl get-sink-volume "$(pactl get-default-sink)" | head -1 | awk '{print ($5 + $12) / 2 "%"}' ;;
ALSA) amixer sget Master | grep '\[[0-9]*\%\]' | sed "s/ /\n/g" | grep '%' | sed 's/\[//;s/\]//g' ;;
@@ -67,6 +74,7 @@ get () {
;;
mute)
case "$AUDIO_SERVER" in
+ WP) wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{m = $3; if (typeof($3)=="unassigned") { m = "[on]" } else { m="[off]" }; print m }' ;;
SNDIO) sndioctl output.mute | cut -d'=' -f2 | sed 's/1/[off]/;s/0/[on]/' ;;
PULSE|PW) pactl get-sink-mute "$(pactl get-default-sink)" | cut -d' ' -f2 | sed 's/no/\[on\]/;s/yes/\[off\]/' ;;
ALSA) amixer sget Master | grep '\[o[fn]' | cut -d' ' -f8 | head -1 ;;
@@ -74,6 +82,7 @@ get () {
;;
both)
case "$AUDIO_SERVER" in
+ WP) wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{m = $3; if (typeof($3)=="unassigned") { m="[on]" } else { m="[off]" }; v = $2 * 100; print m v "%" }' ;;
SNDIO) printf "%s%s%%" "$(sndioctl output.mute | cut -d'=' -f2 | sed 's/1/[off]/;s/0/[on]/')" "$(sndioctl output.level | rev | cut -d'.' -f1 | rev | cut -c 1,2)" ;;
PULSE|PW) printf "%s%s\n" "$(pactl get-sink-mute "$(pactl get-default-sink)" | cut -d' ' -f2 | sed 's/no/\[on\]/;s/yes/\[off\]/')" "$(pactl get-sink-volume "$(pactl get-default-sink)" | head -1 | awk '{print ($5 + $12) / 2 "%"}')" ;;
ALSA) printf "%s%s" "$(amixer sget Master | grep '\[o[fn]' | cut -d' ' -f8 | head -1)" "$(amixer sget Master | grep '\[[0-9]*\%\]' | sed "s/ /\n/g" | grep '%' | sed 's/\[//;s/\]//g')" ;;
diff --git a/volsv.1 b/volsv.1
index 0af752d..d46b383 100644
--- a/volsv.1
+++ b/volsv.1
@@ -19,7 +19,8 @@ Volsv is a free software, POSIX shell compliant script ZachIR wrote in 2020, and
has been modifying since, for simple volume control. Volsv controls volume for
pulseaudio, pipewire, sndio, or alsa (depending on what it detects). More sound
servers are intended to be added in future versions. Volsv depends on amixer for
-alsa, pactl for pulseaudio and pipewire, and/or mixerd for sndio.
+alsa, wpctl for pipewire with wireplumber, pactl for pulseaudio and pipewire
+without wireplumber, and/or mixerd for sndio.
.SH OPTIONS
.TP
.B \-h