Created
February 20, 2014 13:34
-
-
Save danboid/9113675 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# j2x - a simple JACK 2 playback device switcher by Dan MacDonald 2014. Licensed under the GNU GPL v3 | |
# Check user has kdialog installed | |
if ! command -v kdialog >/dev/null; then | |
echo You must install kdialog to use j2x. Debian and Ubuntu users should install kde-baseapps-bin | |
exit 1 | |
fi | |
# Check user has jack_control installed | |
if ! command -v jack_control >/dev/null; then | |
kdialog --error "You need jack_control to use j2x.\njack_control is included with JACK2 (jackd2)" | |
exit 1 | |
fi | |
# Get list of attached ALSA devices and format output for kdialog menu | |
ALSA_DEVICES=$(cat /proc/asound/cards | cut -c 5-19 | awk 'NR%2 != 0'| sed 's/ *$//' | awk '{print $0,$0;}' | tr '\n' ' ') | |
DEVICE_CHOICE=0 | |
while [ DEVICE_CHOICE != "1" ]; do | |
# Display and switch between ALSA devices | |
DEVICE_CHOICE=$(kdialog --menu "Select JACK2 output device:" $ALSA_DEVICES) | |
jack_control dps playback hw:$DEVICE_CHOICE,0 | |
jack_control sm | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment