Got this to work finally!
Just create a helper script file
/home/volumio/udev-playcd.sh (don’t forget to chmod +x it!)
#!/bin/bash
echo /home/volumio/playcd.sh | at now
/etc/udev/rules.d/99-local.rules
KERNEL=="sr[0-9]", ACTION=="change", ENV{ID_CDROM_MEDIA}=="1", ENV{ID_CDROM_MEDIA_STATE}!="blank", RUN+="/home/volumio/udev-playcd.sh &"
Then your /home/volumio/playcd.sh is…
#!/bin/bash
curl localhost:3000/api/v1/v1/browse?uri=audiocd | jq '.navigation.lists[0].items' > myjson.txt
curl -i --header "Content-Type: application/json" localhost:3000/api/v1/addToQueue --data "$(cat myjson.txt)"
curl -i --header "Content-Type: application/json" localhost:3000/api/v1/commands/?cmd=volume&volume=50
curl -i --header "Content-Type: application/json" localhost:3000/api/v1/commands/?cmd=play&N=1
eject -x 4 /dev/cdrom
The eject command is optional—prevents my CD drive overspinning noisily; credit nanomesher