#!/bin/sh # ------- # File: lliurex-qjackctl-config # Description: qjackctl configuration script for LliureX # Authors: # Luis Antonio Garcia Gisbert # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA # -------- # variables LLIUREX_QJACK_DIR=".config/rncbc.org" LLIUREX_QJACK_FILE="QjackCtl.conf" LLIUREX_QJACKCONF="$HOME/$LLIUREX_QJACK_DIR/$LLIUREX_QJACK_FILE" LLIUREX_QJACKTEMPLATE="/usr/share/lliurex-qjackctl/$LLIUREX_QJACK_FILE" LLIUREX_QJACK_TEMPLATE_INTERFACE="/usr/share/lliurex-qjackctl/settings_" JACK_TMP_TEMPLATE="$(tempfile)" TMP_SETTINGS="$(tempfile)" ADD_DEFAULT_PRESET="" eval $(llxcfg-showvars JACK_INTERFACE_NAMES JACK_INTERFACE_DEVICES) [ "$JACK_INTERFACE_NAMES" -a "$JACK_INTERFACE_DEVICES" ] || exit 0 if [ ! -f "$LLIUREX_QJACKCONF" ] ; then mkdir -p "$HOME/$LLIUREX_QJACK_DIR" cp "$LLIUREX_QJACKTEMPLATE" "$JACK_TMP_TEMPLATE" ADD_DEFAULT_PRESET="Y" else cat $LLIUREX_QJACKCONF > $JACK_TMP_TEMPLATE fi for INAME in $JACK_INTERFACE_NAMES ; do LLIUREX_JACK_PROFILE="lliurex_$INAME" IDEVICE="${JACK_INTERFACE_DEVICES%% *}" echo "$INAME $IDEVICE ($JACK_INTERFACE_DEVICES)" JACK_INTERFACE_DEVICES=${JACK_INTERFACE_DEVICES#* } if ! grep -q "^$LLIUREX_JACK_PROFILE\\\\" $LLIUREX_QJACKCONF ; then ID_PRESETS=`sed -ne "/^\[Presets\]/,/^\[/{/^Preset.\+=/s%^Preset\([^=]\+\)=.*$%\1%p}" $JACK_TMP_TEMPLATE |sort -n |tail -1` ID_PRESETS=$(($ID_PRESETS +1)) sed -i -e "/^\[Presets\]/aPreset$ID_PRESETS=$LLIUREX_JACK_PROFILE" $JACK_TMP_TEMPLATE SETTINGS_TEMPLATE="${LLIUREX_QJACK_TEMPLATE_INTERFACE}default" if [ -r "${LLIUREX_QJACK_TEMPLATE_INTERFACE}$INAME" ] ; then SETTINGS_TEMPLATE="${LLIUREX_QJACK_TEMPLATE_INTERFACE}$INAME" fi sed -e "s%^%$LLIUREX_JACK_PROFILE\\\%" "$SETTINGS_TEMPLATE" > "$TMP_SETTINGS" sed -i -e "/^\[Settings\]/r$TMP_SETTINGS" "$JACK_TMP_TEMPLATE" fi echo "$LLIUREX_JACK_PROFILE\Interface" sed -i -e "s%^$LLIUREX_JACK_PROFILE\\\Interface=.*$%$LLIUREX_JACK_PROFILE\\\Interface=hw:$IDEVICE%g" $JACK_TMP_TEMPLATE if [ $JACK_INTERFACE_NAMES = "Audiophile192" -o $JACK_INTERFACE_NAMES = "M2496" ] ; then sed -i -e "s%^$LLIUREX_JACK_PROFILE\\\InDevice=.*$%$LLIUREX_JACK_PROFILE\\\InDevice=\"hw:$IDEVICE,1\"%g" $JACK_TMP_TEMPLATE sed -i -e "s%^$LLIUREX_JACK_PROFILE\\\OutDevice=.*$%$LLIUREX_JACK_PROFILE\\\OutDevice=\"hw:$IDEVICE,1\"%g" $JACK_TMP_TEMPLATE sed -i -e "s%_@_ASOUND_DEVICE_@_%$IDEVICE%g" $JACK_TMP_TEMPLATE fi done if [ "$ADD_DEFAULT_PRESET" ] ; then DEF_PROFILE=${JACK_INTERFACE_NAMES%% *} echo $DEF_PROFILE sed -i -e "s%^DefPreset=.*$%DefPreset=lliurex_$DEF_PROFILE%" "$JACK_TMP_TEMPLATE" fi llxcfg-install $JACK_TMP_TEMPLATE $LLIUREX_QJACKCONF rm -f "$JACK_TMP_TEMPLATE" rm -f "$TMP_SETTINGS"