summaryrefslogtreecommitdiffstats
path: root/.local/bin
diff options
context:
space:
mode:
authorProf-Bloodstone <46570876+Prof-Bloodstone@users.noreply.github.com>2021-05-08 01:42:23 +0200
committerGitHub <noreply@github.com>2021-05-08 01:42:23 +0200
commitfe9be01d591f2eb2f2c0b739e7de5a11ef46b418 (patch)
tree020a1b8ea6dfad0fbe220d047045b570be65695e /.local/bin
parent5e53f5f467829c742586d38eb17a1c3efd18f6bf (diff)
downloadeibhear-fe9be01d591f2eb2f2c0b739e7de5a11ef46b418.tar.gz
eibhear-fe9be01d591f2eb2f2c0b739e7de5a11ef46b418.tar.zst
eibhear-fe9be01d591f2eb2f2c0b739e7de5a11ef46b418.zip
dmenumount: Don't show partitions with children
This PR makes `dmenumount` script filter out all devices, which have childs. This way it won't suggest to mount your partitions which have LUKS or lvm setup on it. If someone knows of a better way to do something, that'd be appreciated :)
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/dmenumount6
1 files changed, 5 insertions, 1 deletions
diff --git a/.local/bin/dmenumount b/.local/bin/dmenumount
index b98b6a3..825ff56 100755
--- a/.local/bin/dmenumount
+++ b/.local/bin/dmenumount
@@ -50,7 +50,11 @@ asktype() { \
}
anddrives=$(simple-mtpfs -l 2>/dev/null)
-usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | grep 'part\|rom' | awk '$4==""{printf "%s (%s)\n",$1,$3}')"
+# Get all block devices which are parents of other devices
+parentnames="$(lsblk -rpo "pkname" | awk 'NR!=1 && $0 != ""' | uniq | xargs printf '^%s$|' | sed 's/|$//')"
+# Get all `part` and `rom` devices, which aren't a parent to another device
+# This allows ommiting partitions which have i.e. crypt or lvm childs
+usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | awk -v parentnames="$parentnames" '$2 ~ "part|rom" && $4=="" && $1 !~ parentnames {printf "%s (%s)\n",$1,$3}')"
if [ -z "$usbdrives" ]; then
[ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit