forked from dinofizz/diskplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
media_change.sh
29 lines (25 loc) · 842 Bytes
/
media_change.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env bash
exec >> /home/pi/mount.log 2>&1
export LC_ALL=en_GB.utf-8
export LANG=en_GB.utf-8
echo "$(date) Start."
echo "$(date) Media change detected on device $1"
device=${1##*/}
lsblk | grep $device
if [ $? -eq 0 ]; then
echo "$(date) Device exists on machine."
echo "$(date) Mounting device $1 to /media/floppy."
/usr/bin/systemd-mount $1 /media/floppy
#runuser -l pi -c 'systemctl --user start spotifyd.service'
#cd /opt
#/opt/player --path /media/floppy/diskplayer.contents
runuser -l pi -c 'player --path /media/floppy/diskplayer.contents'
/usr/bin/systemd-mount --umount /media/floppy
else
echo "$(date) Device does not exist on machine."
#cd /opt
#/opt/player --pause
runuser -l pi -c '/home/pi/player --pause'
#systemctl stop spotifyd.service
fi
echo "$(date) End."