From 0f87a8ed80b32ae9415be063e7e258e44dbc5fd8 Mon Sep 17 00:00:00 2001 From: Santiago Lo Coco Date: Fri, 8 Dec 2023 19:39:58 -0300 Subject: [PATCH] Update volume scripts --- blocks.def/volume.sh | 8 +++++--- blocks.def/volume_button.sh | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/blocks.def/volume.sh b/blocks.def/volume.sh index 878b014..c7b9eb0 100755 --- a/blocks.def/volume.sh +++ b/blocks.def/volume.sh @@ -8,9 +8,11 @@ ICONspeakermute="🔕" ICONspeaker="🔔" ICONheadphone="🎧" -SINKHDMI=alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1 -#SINKHDMI=alsa_output.pci-0000_01_00.1.hdmi-stereo +#SINKHDMI=alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1 +SINKHDMI=alsa_output.pci-0000_01_00.1.hdmi-stereo SINKANALOG=alsa_output.pci-0000_00_1b.0.analog-stereo +#alsa_output.pci-0000_00_1b.0.analog-surround-51 + checkDefaultSink() { if [ -v LAPTOP ]; then @@ -18,7 +20,7 @@ checkDefaultSink() { return fi - PACTLOUTPUT=`pactl info` + PACTLOUTPUT="$(pactl get-default-sink)" if echo $PACTLOUTPUT | grep -q "$SINKANALOG"; then SINK=$SINKANALOG diff --git a/blocks.def/volume_button.sh b/blocks.def/volume_button.sh index f096162..a7c00c7 100755 --- a/blocks.def/volume_button.sh +++ b/blocks.def/volume_button.sh @@ -1,11 +1,11 @@ #!/bin/sh -SINKHDMI=alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1 -#SINKHDMI=alsa_output.pci-0000_01_00.1.hdmi-stereo +#SINKHDMI=alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1 +SINKHDMI=alsa_output.pci-0000_01_00.1.hdmi-stereo SINKANALOG=alsa_output.pci-0000_00_1b.0.analog-stereo checkDefaultSink() { - PACTLOUTPUT=`pactl info` + PACTLOUTPUT="$(pactl get-default-sink)" if echo $PACTLOUTPUT | grep -q "$SINKANALOG"; then SINK=$SINKANALOG @@ -19,8 +19,18 @@ changeDefaultSink() { if [ "$SINK" = "$SINKANALOG" ]; then pactl set-default-sink $SINKHDMI + if [ $? -ne 0 ]; then + INDEX="$(pactl list short cards | grep alsa_card.pci-0000_01_00.1 | cut -d$'\t' -f1)" + pactl set-card-profile "$INDEX" output:analog-stereo + pactl set-default-sink $SINKHDMI + fi elif [ "$SINK" = "$SINKHDMI" ]; then pactl set-default-sink $SINKANALOG + if [ $? -ne 0 ]; then + INDEX="$(pactl list short cards | grep alsa_card.pci-0000_00_1b.0 | cut -d$'\t' -f1)" + pactl set-card-profile "$INDEX" output:analog-stereo + pactl set-default-sink $SINKANALOG + fi fi }