summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornikolaus <nikolaus@fishbox.fritz.box>2022-12-27 08:28:12 +0100
committernikolaus <nikolaus@fishbox.fritz.box>2022-12-27 08:28:12 +0100
commit3a9084f770fa22189b378f5c8848fa51b08756b2 (patch)
tree829369414d4b0112a4c1cf4902e11dd998eb2546
parent130939ba4e650bff9ef43434e28d55ec7ac30d5e (diff)
A new script for mounting/unmounting in OpenBSD
-rwxr-xr-xdmenumount15
1 files changed, 15 insertions, 0 deletions
diff --git a/dmenumount b/dmenumount
new file mode 100755
index 0000000..dde420b
--- /dev/null
+++ b/dmenumount
@@ -0,0 +1,15 @@
+#!/bin/sh
+# Dependency: https://github.com/RHL120/openbsd_lsblk
+# Idea: If you want to, change doas.conf to allow lsblk to run without password (lsblk requires privileges).
+# USAGE: use "dmenumount m" and "dmenumount u" for mounting and unmounting, respectively.
+# Put something like SHCMD("sh -c 'st -e dmenumount m'") as a binding into you WM config (in my case DWM).
+
+if [[ $1 == m ]]; then
+ disk=$(echo $(doas lsblk | awk 'BEGIN{OFS=""} {if ($4=="") print $1, "(", $2, ")"}' | sed -r '/[0-9]\(|\(.*[0-9]b\)/d' | sed -e 's/|-//g' | dmenu) | sed -E 's/\(.*\)//g')
+ [[ -z "$disk" ]] && exit || doas mount /dev/$disk /mnt
+elif [[ $1 == u ]]; then
+ dir=$(mount | awk 'BEGIN{OFS=""} !/'sd0'/ {print $3,"(",$1,")"}' | dmenu | sed -E 's/\(.*\)//')
+ [[ -z "$dir" ]] && exit || doas umount $dir
+else
+ echo "Not a valid option."
+fi