Re: [LAU] Help needed with Scripting in QjackCtl

From: Robin Gareus <robin@email-addr-hidden>
Date: Sun Feb 27 2011 - 16:50:28 EET

On 02/26/2011 11:32 PM, david wrote:
> Dan Capp wrote:
>> Thanks Renato. But what I'm trying to do is use the "Script" in Setup
>> to make QjackCtl automatically load a certain preset without me having
>> to do it. The reason I want to do this is because: 1) I have QjackCtl
>> set to start automatically on system startup and I also have QjackCtl
>> set to "start jack server" straight away when loaded. At the moment it
>> automatically loads the last preset used, so if I've been using
>> "firewire" and then I shut my computer down, when I start it again
>> QjackCtl loads automatically and tries to load the "firewire"
>> driver/preset even when the firewire isn't connected, so I get loads
>> of error messages. And 2) whilst studying the options in QjackCtl (I'm
>> new to Linux audio and excited) I noticed that there seems to be the
>> facility to make it load specified presets automatically and I wanted
>> to try it, but it doesn't seem to work and I don't know if I'm getting
>> the "meta-symbol arguments" right (I'm totally new to them).
>>
>> This relates to an earlier request/thread I made in LAU. It's not a
>> big deal if I can't do this as it just means I need to always remember
>> to manually switch QjackCtl to my "alsa" preset whenever I turn my
>> firewire device off so that it doesn't ever try and load "firewire"
>> when the device isn't there, like you said. I just hate error messages
>> and I like automation - some kind of Obsessive Compulsive thing I have
>> maybe ;). It just seems like QjackCtl offers an easy solution to my
>> problem and I'm not using it right.
>
> Hmm, maybe make a script that checks to see if firewire device is
> connected. If true, it starts JACK with the firewire backend, otherwise,
> it starts with your ALSA backend. Maybe you could run that script on
> startup.

Here's such a script. It's ripped off http://rg42.org/wiki/jack2contol
and uses 'dbus' to control a running qjackctl instance.

Install:
 0) launch qjackctl

 1) qjackctl->Setup->Misc->Enable D-Bus interface

 1a) (only for jack2 with dbus enabled) add
         killall -9 jackdbus
    to qjackctl->Setup->Options->Execute script after shutdown

 2) save the script below to a file and make it executable:
    eg. `chmod +x $HOME/bin/myqjackctl.sh`

 3) modify the script according to your soundcard(s) and presets

 4) run the script on each system-boot or after dis/connecting the
    external card.

 5) note that this works, but that it's not an elegant solution :-p
 5a) stay tuned for http://rg42.org/blog/jack2dbus

---------------------8<-----------------------
#!/bin/sh

## stop jackd
dbus-send --system /org/rncbc/qjackctl org.rncbc.qjackctl.stop
sleep 1

## default qjackctl preset: "intel"
PRESET="intel"

## try to detect USB-UA25 -> qjackctl preset "ua25"
grep "UA25" /proc/asound/cards >/dev/null && PRESET="ua25"

## change qjackctl's preset
dbus-send --system /org/rncbc/qjackctl \
                    org.rncbc.qjackctl.preset string:$PRESET

## tell qjackctl to start jackd
dbus-send --system /org/rncbc/qjackctl org.rncbc.qjackctl.start
---------------------8<-----------------------

ciao,
robin
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-user
Received on Sun Feb 27 20:15:01 2011

This archive was generated by hypermail 2.1.8 : Sun Feb 27 2011 - 20:15:02 EET