You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.1 KiB
Bash
48 lines
1.1 KiB
Bash
8 years ago
|
#!/bin/sh
|
||
8 years ago
|
#
|
||
8 years ago
|
|
||
8 years ago
|
FD="/dev/sda"
|
||
|
FLOPPY="/media/floppy"
|
||
|
MAINPY="${FLOPPY}/main.py"
|
||
8 years ago
|
PYRUN="python ${MAINPY}"
|
||
8 years ago
|
MAINPD="${FLOPPY}/main.pd"
|
||
8 years ago
|
PDRUN="pd -lib import -path /usr/local/lib/pd-externals/net/ -path /usr/local/lib/pd-externals/osc/ -oss -r 48000 -rt -nogui ${MAINPD}"
|
||
8 years ago
|
|
||
8 years ago
|
stdbuf -oL -- udevadm monitor --udev -p ${FD} | while read -r -- STATE _ _ _ _
|
||
8 years ago
|
do
|
||
8 years ago
|
if [ "${STATE}" = "DISK_MEDIA_CHANGE=1" ]
|
||
8 years ago
|
then
|
||
|
echo "change detected"
|
||
8 years ago
|
if [ "$(udisksctl info -b ${FD} | grep filesystem)" ]
|
||
8 years ago
|
then
|
||
8 years ago
|
echo "floppy in (fs detected)"
|
||
8 years ago
|
udisksctl mount -b ${FD} --no-user-interaction
|
||
|
if [ -e "${MAINPY}" ]
|
||
|
then
|
||
|
echo "main.py found"
|
||
8 years ago
|
$(${PYRUN})&
|
||
8 years ago
|
fi
|
||
|
if [ -e "${MAINPD}" ]
|
||
|
then
|
||
|
echo "main.pd found"
|
||
8 years ago
|
$(${PDRUN})&
|
||
8 years ago
|
fi
|
||
8 years ago
|
else
|
||
|
echo "floppy out (no fs detected)"
|
||
8 years ago
|
if [ "$(pgrep -f '^python')" ]
|
||
8 years ago
|
then
|
||
|
echo "python still running ... killing"
|
||
|
pkill -9 python
|
||
|
fi
|
||
8 years ago
|
if [ "$(pgrep -f '^pd')" ]
|
||
|
then
|
||
|
echo "pd still running ... killing"
|
||
|
pkill -9 pd
|
||
|
fi
|
||
|
|
||
8 years ago
|
fi
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
|