Based on the approach in that script (the one that 'universally' works
for me and Carsten), I've made a script that creates the udev rules file
and adds it to the list of backed up files.  So this would replace steps
1, 2 and 3 above - put this script into a file, make it executable, then
run it with the name of your sound card as the only command line
parameter, e.g. './imaketherules.sh DAC'

I call it 'imaketherules.sh' :)

Code:
--------------------
    #!/bin/sh
  
  # one command line parameter: the name of the 'CARD', as used in the 
squeezelite command line
  cardname=$1
  
  # look for cardname in /proc/asound/cards to determine card number
  cardno=$(cat /proc/asound/cards | grep -m 1 $cardname | awk {'print $1'})
  
  # extract idVendor and idProduct from /proc/asound/card<n>/usbid
  usbid=$(cat /proc/asound/card$cardno/usbid)
  idVendor=$(echo $usbid | awk -F: {'print $1'})
  idProduct=$(echo $usbid | awk -F: {'print $2'})
  
  # create udev rules
  rule_add='SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="'$idVendor'", 
ATTR{idProduct}=="'$idProduct'", RUN+="/home/tc/SQLITE-control.sh restart 
$kernel'
  rule_remove='SUBSYSTEM=="usb", ACTION=="remove", 
RUN+="/home/tc/SQLITE-control.sh stop $kernel'
  
  # create rules file
  rulesfile=etc/udev/rules.d/10-$cardname.rules
  echo $rule_add > /$rulesfile
  echo $rule_remove >> /$rulesfile
  
  # add rules file to /opt/.filetool.lst
  sed -i "\#$rulesfile#d" /opt/.filetool.lst #remove all previous matching 
entries, to make sure it's only listed once
  echo $rulesfile >> /opt/.filetool.lst
  
--------------------


------------------------------------------------------------------------
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

Reply via email to