diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-06-10 18:58:52 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-06-10 18:58:52 +0200 |
| commit | b98e05ba63f2e108df634b4d9f9e5530769c6b80 (patch) | |
| tree | a1d3a7f20e826d264f2a6b2141b7b1bfa7debb6f /dmenu-unmount | |
| parent | ed61c5f085cebb86d3d3a34ce01ec22069c1fc70 (diff) | |
| download | scripts-b98e05ba63f2e108df634b4d9f9e5530769c6b80.tar.gz scripts-b98e05ba63f2e108df634b4d9f9e5530769c6b80.zip | |
Added scripts and readme
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)" | ||
