#!/bin/sh
if [ -f $HOME/.dmenurc ]; then
. $HOME/.dmenurc
else
DMENU='dmenu -i'
fi
drive=$(mount | perl -ne 'print qq/$_\n/ for /^\/dev\/(?:mapper\/)?[a-z0-9]+ .* \/media\/(.*) type/' | $DMENU -p 'umount:')
if [ "$drive" = '' ]
then
exit
fi
udevil unmount "/media/$drive"
if [ $? -eq 0 ]
then
notify-send "$drive umounted"
elif [ $? -eq 1 ]
then
notify-send "$drive is busy"
else
notify-send "something's very wrong! ;)"
fi