From 01fee33d0f8367f8e780655077d8d0c49994b579 Mon Sep 17 00:00:00 2001 From: dtb Date: Sun, 21 Aug 2022 15:58:26 -0400 Subject: [PATCH] fixing volume(1): separating out the system-dependent portions --- bin/volume.netbsd | 18 ++++++++++++++++++ bin/volume.pulseaudio | 20 ++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 bin/volume.netbsd create mode 100755 bin/volume.pulseaudio diff --git a/bin/volume.netbsd b/bin/volume.netbsd new file mode 100755 index 0000000..3ea0f74 --- /dev/null +++ b/bin/volume.netbsd @@ -0,0 +1,18 @@ +#!/bin/sh -e + +# NetBSD 9.2 STABLE 2021-07 + +case "$1" in +a*) + audioctl -w play.gain=$2 >/dev/null + exit $? + ;; + +s*) # hacky + audioctl -a \ + | grep "play\.gain" \ + | cut -d '=' -f 2 + exit $? + ;; +esac +exit 1 diff --git a/bin/volume.pulseaudio b/bin/volume.pulseaudio new file mode 100755 index 0000000..c8cc2ff --- /dev/null +++ b/bin/volume.pulseaudio @@ -0,0 +1,20 @@ +#!/bin/sh -e + +# pactl 15.0 compiled+linked with libpulse 15.0.0 + +case "$argv1" in +a*) + pactl set-sink-volume @DEFAULT_SINK@ $2% + exit $? + ;; + +s*) # really hacky, gets the job done + # gets the volume % of Lchan specifically + pactl get-sink-volume @DEFAULT_SINK@ \ + | sed q \ + | cut -d '/' -f 2 \ + | xargs echo \ + | sed s/'%'// + ;; +esac +exit 1