#!/bin/sh # FD="/dev/sda" FLOPPY="/media/floppy" MAINPY="${FLOPPY}/main.py" MAINPD="${FLOPPY}/main.pd" stdbuf -oL -- udevadm monitor --udev -p ${FD} | while read -r -- STATE _ _ _ _ do if [ "${STATE}" = "DISK_MEDIA_CHANGE=1" ] then echo "change detected" if [ "$(udisksctl info -b ${FD} | grep filesystem)" ] then echo "floppy in (fs detected)" udisksctl mount -b ${FD} --no-user-interaction if [ -e "${MAINPY}" ] then echo "main.py found" $(python ${MAINPY})& fi if [ -e "${MAINPD}" ] then echo "main.pd found" fi else echo "floppy out (no fs detected)" if [ "$(pgrep python)" ] then echo "python still running ... killing" pkill -9 python fi fi fi done