pgf wrote: > Since you're thinking of looking at my script, here's a cleaned up > version. It makes it a little more obvious where to put one's > commands. > > I call it "watch_usb_audio". >
That's great - so many neat little tricks that I've not seen before, as befits a busybox contributor! Thanks for posting. I shall enjoy playing with that tomorrow. Some immediate thoughts: 1) Audiodev can be read from /usr/local/etc/pcp/pcp.cfg. That would make it completely general, and would mean it doesn't need a command line argument. It would also mean it would adapt to a different DAC when it is configured in the pCP Squeezelite settings. I did this in the udev script with Code: -------------------- cardname=$(cat /usr/local/etc/pcp/pcp.cfg | grep ^OUTPUT | awk -FCARD= {'print $2'} | awk -F, {'print $1'}) -------------------- but I saw the pCP team's much neater way of doing it in the init.d script: Code: -------------------- # Read from config file . /usr/local/etc/pcp/pcp.cfg -------------------- The cardname is then part of the $OUTPUT variable, e.g. "hw:CARD=DragonFly,DEV=0", from which 'DragonFly' would need to be extracted. 2) Do you have any thoughts on the frequency that this script checks for the DAC? You've currently set 4 seconds, but how much of a drain on resources would it cause if that was, say, 1 second? Maybe make this a command line argument? 3) If you put the log file in /var/log/, and precede its name with 'pcp_', it will show up in the pCP -> Diagnostics -> Logs page, so users won't have to use a separate shell to see what's going on. It needs root permissions to write to this folder, but I think that's OK because User Commands are run as root. 4) For my own setup I prefer that Squeezelite is soft powered on when the DAC is turned on, regardless of its previous soft power state, so I've been learning about the necessary JSON commands to do that this evening. So for my own copy I'm going to add a function to do that and add it to the commands that are run when the device appears. 5) There's at least one user of the udev script who does not want Squeezelite to be killed when the DAC is powered off. I added the --nostop option so that the 'remove' udev rule was omitted in the installation. I wonder if a --nostop command line option could be added to your script to achieve the same result. Whilst I'll be happy to do these modifications for myself, I'm more than keen to see how an experienced programmer would make them :). I learn a little bit more every time I look at someone else's code. ------------------------------------------------------------------------ chill's Profile: http://forums.slimdevices.com/member.php?userid=10839 View this thread: http://forums.slimdevices.com/showthread.php?t=113661 _______________________________________________ unix mailing list unix@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/unix