diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-06-20 23:01:09 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-06-20 23:01:09 +0200 |
| commit | 581865ee0c8b8aea872f053d804a41fb5f416b17 (patch) | |
| tree | 9a2f99ea48c31629a5c3c42b0454483982cdbfed /dmenu-unmount | |
| parent | c5d101ab2c9db3b1a001cb56953cb90b24f8fdcf (diff) | |
| download | scripts-581865ee0c8b8aea872f053d804a41fb5f416b17.tar.gz scripts-581865ee0c8b8aea872f053d804a41fb5f416b17.zip | |
Various shellcheck fixes (www.shellcheck.net)
Diffstat (limited to '')
| -rwxr-xr-x | dmenu-unmount | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/dmenu-unmount b/dmenu-unmount index 2771ecc..8f7a27f 100755 --- a/dmenu-unmount +++ b/dmenu-unmount | |||
| @@ -1,14 +1,20 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | # Prompts selection for mounted devices and unmounts the selected one | 3 | # Prompts selection for mounted devices and unmounts the selected one |
| 4 | # Requires: udevil, dmenu (or similar), notify-send or similar (optional) | ||
| 5 | |||
| 4 | # Usage: dmenu-unmount [-m menu] [-w writer] | 6 | # Usage: dmenu-unmount [-m menu] [-w writer] |
| 5 | # Example: dmenu-unmount -m slmenu -w echo | 7 | # Example: dmenu-unmount -m slmenu -w echo |
| 6 | # Requires: udevil, dmenu (or similar), notify-send or similar (optional) | ||
| 7 | 8 | ||
| 8 | menu=dmenu | 9 | menu=dmenu |
| 9 | #writeout=notify-send | 10 | #writeout=notify-send |
| 10 | writeout="notify push" | 11 | writeout="notify push" |
| 11 | 12 | ||
| 13 | usage() { | ||
| 14 | echo "Usage: dmenu-unmount [-m MENU] [-w WRITER]" | ||
| 15 | echo "Example: dmenu-unmount -m slmenu -w echo" | ||
| 16 | } | ||
| 17 | |||
| 12 | while getopts "m:w:" opt; do | 18 | while getopts "m:w:" opt; do |
| 13 | case "$opt" in | 19 | case "$opt" in |
| 14 | m) | 20 | m) |
| @@ -17,9 +23,13 @@ while getopts "m:w:" opt; do | |||
| 17 | w) | 23 | w) |
| 18 | writeout="$OPTARG" | 24 | writeout="$OPTARG" |
| 19 | ;; | 25 | ;; |
| 26 | *) | ||
| 27 | usage | ||
| 28 | exit 1 | ||
| 29 | ;; | ||
| 20 | esac | 30 | esac |
| 21 | done | 31 | done |
| 22 | shift `expr $OPTIND - 1` | 32 | shift $((OPTIND - 1)) |
| 23 | 33 | ||
| 24 | listdev=$(grep "media" /proc/mounts | sed 's/\/media.*\///g' | \ | 34 | listdev=$(grep "media" /proc/mounts | sed 's/\/media.*\///g' | \ |
| 25 | awk '{print $1" ("$2")"}') | 35 | awk '{print $1" ("$2")"}') |
| @@ -31,11 +41,10 @@ else | |||
| 31 | if [ -n "$seldev" ]; then | 41 | if [ -n "$seldev" ]; then |
| 32 | udevil unmount "$seldev" | 42 | udevil unmount "$seldev" |
| 33 | failed=$(udevil info "$seldev" | grep mounted | awk '{print $3}') | 43 | failed=$(udevil info "$seldev" | grep mounted | awk '{print $3}') |
| 34 | if [ $failed -eq 1 ]; then | 44 | if [ "$failed" -eq 1 ]; then |
| 35 | $writeout "Unmount FAILED" "Device is still mounted!" | 45 | $writeout "Unmount FAILED" "Device is still mounted!" |
| 36 | else | 46 | else |
| 37 | $writeout "Device unmounted" | 47 | $writeout "Device unmounted" |
| 38 | fi | 48 | fi |
| 39 | fi | 49 | fi |
| 40 | fi | 50 | fi |
| 41 | # notify-send "$(udisksctl unmount -b $seldev)" | ||
