DietPi user here. Because I'm pretty new to Linux I tried to implement
chill his script, but ran into quite a few difficulties.
So after reading a lot about systemd services and udev I found a much
simpeler and elegant solution to trigger a restart and stop of
squeezelite when a USB DAC gets connected or disconnected. Sorry for
hijacking your thread, but I'd like to share this information, so others
with DietPi could also benefit from it
Here we go:
Create a file called '/etc/udev/rules.d/10-C20.rules' with the following
content:
Code:
--------------------
SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="....",
ATTR{idProduct}=="....", TAG+="systemd",
ENV{SYSTEMD_WANTS}="squeezelite.service"
--------------------
Lookup the vendor and product id by switching off the DAC. Then run
*udevadm monitor -p -k -u* and switch the DAC back on again.
Then edit this file:
/etc/systemd/system/squeezelite.service.d/dietpi-services_edit.conf
Code:
--------------------
[Unit]
Description=SqueezeLite (DietPi)
Requires=sys-devices-platform-soc-3f980000.usb-usb1-1\x2d1-1\x2d1.2-1\x2d1.2:1.0-sound-card1.device
BindsTo=sys-devices-platform-soc-3f980000.usb-usb1-1\x2d1-1\x2d1.2-1\x2d1.2:1.0-sound-card1.device
After=sys-devices-platform-soc-3f980000.usb-usb1-1\x2d1-1\x2d1.2-1\x2d1.2:1.0-sound-card1.device
[Service]
User=squeezelite
Restart=on-failure
RestartSec=5s
ExecStart=
ExecStart=/usr/bin/squeezelite -o hw:CARD=C20,DEV=0 -a 4096:8096:32:0 -C 5 -n
'DietPi-Squeezelite' -f /var/log/squeezelite.log -D :dop
[Install]
WantedBy=sys-devices-platform-soc-3f980000.usb-usb1-1\x2d1-1\x2d1.2-1\x2d1.2:1.0-sound-card1.device
--------------------
Make sure the DAC is connected and powered. Then look up the full device
path of your DAC by running *systemctl list-units --all --full | grep
".device"* and add it to 'Requires', 'BindsTo', 'After' and 'WantedBy'.
Change the squeezelite parameters to match yours.
Reboot and you're done!
Cheers!
------------------------------------------------------------------------
4]4's Profile: http://forums.slimdevices.com/member.php?userid=71351
View this thread: http://forums.slimdevices.com/showthread.php?t=113661
_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix