diff options
Diffstat (limited to '')
| -rwxr-xr-x | dmenu-unmount | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/dmenu-unmount b/dmenu-unmount new file mode 100755 index 0000000..c0b387a --- /dev/null +++ b/dmenu-unmount | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Prompts selection for mounted devices and unmounts the selected one | ||
| 4 | # Requires: udevil, dmenu (or similar), notify-send (optional) | ||
| 5 | |||
| 6 | menu=${MENU:-dmenu} | ||
| 7 | writeout="notify-send" # Change this to whatever you want, e.g. echo | ||
| 8 | |||
| 9 | listdev=$(grep "media" /proc/mounts | sed 's/\/media.*\///g' | \ | ||
| 10 | awk '{print $1" ("$2")"}') | ||
| 11 | |||
| 12 | if [ -z "$listdev" ]; then | ||
| 13 | $writeout "Nothing to unmount" | ||
| 14 | else | ||
| 15 | seldev=$(echo "$listdev" | $menu | awk '{print $1}') | ||
| 16 | if [ -n "$seldev" ]; then | ||
| 17 | udevil unmount "$seldev" | ||
| 18 | failed=$(udevil info "$seldev" | grep mounted | awk '{print $3}') | ||
| 19 | if [ $failed -eq 1 ]; then | ||
| 20 | $writeout "Unmount FAILED" "Device is still mounted!" | ||
| 21 | else | ||
| 22 | $writeout "Device unmounted" | ||
| 23 | fi | ||
| 24 | fi | ||
| 25 | fi | ||
| 26 | # notify-send "$(udisksctl unmount -b $seldev)" | ||
