diff options
author | awy <awy@awy.one> | 2025-07-29 03:42:18 +0300 |
---|---|---|
committer | awy <awy@awy.one> | 2025-07-29 03:42:18 +0300 |
commit | ef6dff4cce15186a66ba34cdd7bd39958ebf7f58 (patch) | |
tree | fcfa61164ca6e79c900b5d11f6afc6b46aaccb84 /.local/bin/dmenumountcifs | |
download | hyprdots-ef6dff4cce15186a66ba34cdd7bd39958ebf7f58.tar.gz |
first commit
Diffstat (limited to '.local/bin/dmenumountcifs')
-rwxr-xr-x | .local/bin/dmenumountcifs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/.local/bin/dmenumountcifs b/.local/bin/dmenumountcifs new file mode 100755 index 0000000..4832213 --- /dev/null +++ b/.local/bin/dmenumountcifs @@ -0,0 +1,19 @@ +#!/bin/sh +# Gives a mew prompt to mount unmounted local NAS shares for read/write. +# Requirements - "%wheel ALL=(ALL) NOPASSWD: ALL" +# +# Browse for mDNS/DNS-SD services using the Avahi daemon... +srvname=$(avahi-browse _smb._tcp -t | awk '{print $4}' | mew -i -p "Which NAS?") || exit 1 +notify-send "Searching for network shares..." "Please wait..." +# Choose share disk... +share=$(smbclient -L "$srvname" -N | rg Disk | awk '{print $1}' | mew -i -p "Mount which share?") || exit 1 +# Format URL... +share2mnt=//"$srvname".local/"$share" + +sharemount() { + mounted=$(mount -v | rg "$share2mnt") || ([ ! -d /mnt/"$share" ] && doas mkdir /mnt/"$share") + [ -z "$mounted" ] && doas mount -t cifs "$share2mnt" -o user=nobody,password="",noperm /mnt/"$share" && notify-send "Netshare $share mounted" && exit 0 + notify-send "Netshare $share already mounted"; exit 1 +} + +sharemount |