From b2ab7e1ad604e3ad979b97abc1d05c50f9c203cd Mon Sep 17 00:00:00 2001 From: pants Date: Sun, 21 Dec 2025 01:29:12 -0800 Subject: [PATCH] use switch and filter vol better --- bin/audioswitch | 17 ++++++++++------- bin/st-vol | 12 +++++++----- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/bin/audioswitch b/bin/audioswitch index 85baded..8b910c1 100755 --- a/bin/audioswitch +++ b/bin/audioswitch @@ -2,10 +2,13 @@ CARD=$(pactl list cards short | grep '1f.3' | awk '{print $2}') CURRENT_SINK=$(pactl info | grep "Default Sink:") dunstctl close-all -if [ "$CURRENT_SINK" = *"iec958"* ]; then - pactl set-card-profile $CARD output:analog-stereo - notify-send "analog out active" -i : -else - pactl set-card-profile $CARD output:iec958-stereo - notify-send "digital out active" -i : -fi +case $CURRENT_SINK in + *iec958*) + pactl set-card-profile $CARD output:analog-stereo + notify-send "analog out active" -i : + ;; + *) + pactl set-card-profile $CARD output:iec958-stereo + notify-send "digital out active" -i : + ;; +esac diff --git a/bin/st-vol b/bin/st-vol index 078d4f9..aa74962 100755 --- a/bin/st-vol +++ b/bin/st-vol @@ -1,7 +1,9 @@ #!/bin/sh VOLUME=$(wpctl get-volume @DEFAULT_SINK@) -if [ $VOLUME =~ "MUTED" ]; then - echo " MUTED" -fi -VOLUME=$(echo $VOLUME | sed s/"Volume: 0."//g) -echo " $VOLUME" +case $VOLUME in + *MUTED*) + echo " MUTED";; + *) + VOLUME=$(echo $VOLUME | awk '{print $2}' | sed 's/^0//;s/\.//') + echo " $VOLUME";; +esac