From 3a9084f770fa22189b378f5c8848fa51b08756b2 Mon Sep 17 00:00:00 2001 From: nikolaus Date: Tue, 27 Dec 2022 08:28:12 +0100 Subject: A new script for mounting/unmounting in OpenBSD --- dmenumount | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 dmenumount 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 -- cgit v1.2.1