forked from streetturtle/awesome-wm-widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pactl: Work around old pactl by a wrapper script
Older versions of pactl, like the one shipped by Debian Bullseye, do not provide the get-* commands, like get-sink-volume or get-sink-mute. Work around them by providing a wrapper script for pactl that provides those commands. Fixes issue streetturtle#390.
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
|
||
PACTL=/usr/bin/pactl | ||
|
||
if [ "$1" = "--help" ]; then | ||
echo "This is wrapper script around ${PACTL} to provide the commands get-sink-volume" | ||
echo "and get-sink-mute if not provided by pactl." | ||
echo "" | ||
${PACTL} "${@}" | ||
fi | ||
|
||
# pactl already provides the get-* commands, so plainly call pactl | ||
if [ -n "$(${PACTL} --help | grep get-)" ]; then | ||
$PACTL "${@}" | ||
fi | ||
|
||
CMD=$1 | ||
DEVICE=$2 | ||
|
||
if [ "${DEVICE}" = "@DEFAULT_SINK@" ]; then | ||
DEVICE=$(pactl info | grep "Default Sink:" | sed "s/.*: *//") | ||
fi | ||
|
||
if [ "${CMD}" = "get-sink-volume" ]; then | ||
pactl list sinks | grep -E "(Sink #|Name:|^\s*Volume:)" | grep -A2 ${DEVICE} | grep "Volume:" | sed "s/^\s*//" | ||
fi | ||
|
||
if [ "${CMD}" = "get-sink-mute" ]; then | ||
pactl list sinks | grep -E "(Sink #|Name:|Mute:)" | grep -A2 ${DEVICE} | grep "Mute:" | sed "s/^\s*//" | ||
fi |