From c99b5a2117487cd8a23f516b5f13ca48e6f257e4 Mon Sep 17 00:00:00 2001 From: Anthony Axenov Date: Wed, 4 Mar 2026 08:37:22 +0800 Subject: [PATCH] audio --switch --- utils/.local/bin/audio | 63 +++++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 16 deletions(-) diff --git a/utils/.local/bin/audio b/utils/.local/bin/audio index 7f0d7dc..1f4137c 100755 --- a/utils/.local/bin/audio +++ b/utils/.local/bin/audio @@ -2,43 +2,74 @@ # available sinks listed here: pactl list sinks +CURRENT_SINK="$(pactl get-default-sink)" +CURRENT_PRESET="$(easyeffects --active-preset output)" LOUD_SINK="alsa_output.pci-0000_00_1f.3.analog-stereo" LOUD_PRESET="Defender" HEAD_SINK="alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo" HEAD_PRESET="Techno" +set_head() { + if [ "$CURRENT_SINK" != "$HEAD_SINK" ]; then + pactl set-default-sink "$HEAD_SINK" || exit 1 + easyeffects --load-preset "$HEAD_PRESET" || exit 2 + echo -e "Current sink\t: $HEAD_SINK" + echo -e "Current preset\t: $HEAD_PRESET" + fi +} + +set_loud() { + if [ "$CURRENT_SINK" != "$LOUD_SINK" ]; then + pactl set-default-sink "$LOUD_SINK" || exit 1 + easyeffects --load-preset "$LOUD_PRESET" || exit 2 + echo -e "Current sink\t: $LOUD_SINK" + echo -e "Current preset\t: $LOUD_PRESET" + fi +} + +show_help() { + echo "Usage: $(basename "$0") [-h|--help|--loud|--head|--switch]" + echo + echo "Switch audio output and apply appropriate easyffects preset." + echo + echo "Options:" + echo " -h, --help Show this help message" + echo " --loud Enable loud speakers" + echo " --head Enable headphones" + echo " --switch Switch between loud and headphones" + echo +} + if [ -z "$1" ]; then - echo -e "Current sink\t: $(pactl get-default-sink)" echo -e "Loud sink\t: $LOUD_SINK" echo -e "Loud preset\t: $LOUD_PRESET" echo -e "Head sink\t: $HEAD_SINK" echo -e "Head preset\t: $HEAD_PRESET" + echo + echo -e "Current sink\t: $CURRENT_SINK" + echo -e "Current preset\t: $CURRENT_PRESET" exit fi if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then - cat <