zondag 5 maart 2017

Kodi ubuntu / linux: autoplay mp3 on USB using udev

Kodi ubuntu / linux autoplay hot-pluggable devices like USB, using udev:

Ideal for building custom music players 

Run:
sudo apt-get install kodi-eventclients-kodi-send



#--------------------------------------------
#/etc/udev/udev.rules.d/9999-usb-play.rules
#Code:

ACTION=="add", KERNELS=="usb*", SUBSYSTEMS=="usb," DRIVERS=="usb",   \
RUN+="/usr/bin/systemd-run /storage/autoplay.sh /dev/%k"


---------------------------------------



#!/bin/bash
#/storage/autoplay.sh chmod +x /storage/autoplay.sh
sleep 10

MP=$(grep "^${1} " /proc/self/mounts | cut -d ' ' -f 2)

shopt -s globstar
shopt -s nullglob
if [! -f ${MP}/pl.m3u ]
 then
for f in ${MP}/*.mp3 ${MP}/**/*.mp3 ${MP}/**/**/*.mp3  ;
do
    if [[ $f != *"*.mp3"*  ]];
then echo "$f" >> "${MP}/pl.m3u" ; fi ; done ;
fi ;
/usr/bin/kodi-send  --action="PlayMedia(\"${MP}/pl.m3u\")

Geen opmerkingen:

Een reactie plaatsen