#!/bin/sh # FLOPPY="/dev/sda" stdbuf -oL -- udevadm monitor --udev -p ${FLOPPY} | while read -r -- STATE _ _ _ _ do if [ "${STATE}" = "DISK_MEDIA_CHANGE=1" ] then echo "change detected" if [ "$(udisksctl info -b ${FLOPPY} | grep filesystem)" ] then echo "floppy in (fs detected)" udisksctl mount -b ${FLOPPY} --no-user-interaction else echo "floppy out (no fs detected)" fi fi done