Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Short script which will move all audio (in/out)put to the USB Headphones
#!/bin/bash -eux
HEADSET="alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo"
HEADSET_MIC="alsa_input.usb-Logitech_Logitech_USB_Headset-00.analog-mono"
#pacmd list-sink-inputs
#pacmd list-source-outputs
pacmd stat | grep -E '^Default (sink|source) name'
pacmd "set-default-sink ${HEADSET}"
pacmd "set-default-source ${HEADSET_MIC}"
pactl set-sink-mute "${HEADSET}" 0
pactl set-sink-volume "${HEADSET}" 70%
pactl set-source-mute "${HEADSET_MIC}" 0
pactl set-source-volume "${HEADSET_MIC}" 50%
INPUTS=`pactl list sink-inputs short | cut -f 1`
for i in $INPUTS; do
pactl move-sink-input $i "${HEADSET}"
done
OUTPUTS=`pactl list source-outputs short | cut -f 1`
for i in $OUTPUTS; do
pactl move-source-output $i "${HEADSET_MIC}"
done
pacmd stat | grep -E '^Default (sink|source) name'
+ HEADSET=alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo
+ HEADSET_MIC=alsa_input.usb-Logitech_Logitech_USB_Headset-00.analog-mono
+ pacmd stat
+ grep -E '^Default (sink|source) name'
Default sink name: alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo
Default source name: alsa_input.usb-Logitech_Logitech_USB_Headset-00.analog-mono
+ pacmd 'set-default-sink alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo'
+ pacmd 'set-default-source alsa_input.usb-Logitech_Logitech_USB_Headset-00.analog-mono'
+ pactl set-sink-mute alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo 0
+ pactl set-sink-volume alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo 70%
+ pactl set-source-mute alsa_input.usb-Logitech_Logitech_USB_Headset-00.analog-mono 0
+ pactl set-source-volume alsa_input.usb-Logitech_Logitech_USB_Headset-00.analog-mono 50%
++ pactl list sink-inputs short
++ cut -f 1
+ INPUTS=20
+ for i in $INPUTS
+ pactl move-sink-input 20 alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo
++ pactl list source-outputs short
++ cut -f 1
+ OUTPUTS=0
+ for i in $OUTPUTS
+ pactl move-source-output 0 alsa_input.usb-Logitech_Logitech_USB_Headset-00.analog-mono
+ grep -E '^Default (sink|source) name'
+ pacmd stat
Default sink name: alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo
Default source name: alsa_input.usb-Logitech_Logitech_USB_Headset-00.analog-mono
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.