aboutsummaryrefslogtreecommitdiff
path: root/dmenu-unmount
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano.tronto@gmail.com>2021-06-10 18:58:52 +0200
committerSebastiano Tronto <sebastiano.tronto@gmail.com>2021-06-10 18:58:52 +0200
commitb98e05ba63f2e108df634b4d9f9e5530769c6b80 (patch)
treea1d3a7f20e826d264f2a6b2141b7b1bfa7debb6f /dmenu-unmount
parented61c5f085cebb86d3d3a34ce01ec22069c1fc70 (diff)
downloadscripts-b98e05ba63f2e108df634b4d9f9e5530769c6b80.tar.gz
scripts-b98e05ba63f2e108df634b4d9f9e5530769c6b80.zip
Added scripts and readme
Diffstat (limited to 'dmenu-unmount')
-rwxr-xr-xdmenu-unmount26
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
6menu=${MENU:-dmenu}
7writeout="notify-send" # Change this to whatever you want, e.g. echo
8
9listdev=$(grep "media" /proc/mounts | sed 's/\/media.*\///g' | \
10 awk '{print $1" ("$2")"}')
11
12if [ -z "$listdev" ]; then
13 $writeout "Nothing to unmount"
14else
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
25fi
26# notify-send "$(udisksctl unmount -b $seldev)"

Generated with cgit - Back to sebastiano.tronto.net