Krolyxon
Commit 32b1abc

Branches

Refs →

dotfiles-x1132b1abc

use rofi for mounter, unmounter

Author
krolxon
Date
2025-08-04 21:46 +0530
Parent
e6a46d6
Commit
32b1abc39ff7e07c18cdae6bddb978ea4afeca37

+8 −8

2 files changed

  1. M .local/bin/mounter +4 −4
  2. M .local/bin/unmounter +4 −4
M .local/bin/mounter View
@@ -1,6 +1,6 @@
11 #!/bin/sh
22
3−# Gives a dmenu prompt to mount unmounted drives. If
3+# Gives a rofi -dmenu prompt to mount unmounted drives. If
44 # they're in /etc/fstab, they'll be mounted automatically. Otherwise, you'll
55 # be prompted to give a mountpoint from already existsing directories. If you
66 # input a novel directory, it will prompt you to create that directory.
@@ -8,16 +8,16 @@
88 getmount() { \
99 [ -z "$chosen" ] && exit 1
1010 # shellcheck disable=SC2086
11− mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")" || exit 1
11+ mp="$(find $1 2>/dev/null | rofi -dmenu -i -p "Type in mount point.")" || exit 1
1212 test -z "$mp" && exit 1
1313 if [ ! -d "$mp" ]; then
14− mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") || exit 1
14+ mkdiryn=$(printf "No\\nYes" | rofi -dmenu -i -p "$mp does not exist. Create it?") || exit 1
1515 [ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp")
1616 fi
1717 }
1818
1919 mountusb() { \
20− chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?")" || exit 1
20+ chosen="$(echo "$usbdrives" | rofi -dmenu -i -p "Mount which drive?")" || exit 1
2121 chosen="$(echo "$chosen" | awk '{print $1}')"
2222 sudo -A mount "$chosen" 2>/dev/null && notify-send "💻 USB mounting" "$chosen mounted." && exit 0
2323 alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not ( -path *%s -prune ) ",$3}')
M .local/bin/unmounter View
@@ -1,12 +1,12 @@
11 #!/bin/sh
22
3−# A dmenu prompt to unmount drives.
3+# A rofi -dmenu prompt to unmount drives.
44 # Provides you with mounted partitions, select one to unmount.
55 # Drives mounted at /, /boot and /home will not be options to unmount.
66
77 unmountusb() {
88 [ -z "$drives" ] && exit
9− chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1
9+ chosen="$(echo "$drives" | rofi -dmenu -i -p "Unmount which drive?")" || exit 1
1010 chosen="$(echo "$chosen" | awk '{print $1}')"
1111 [ -z "$chosen" ] && exit
1212 sudo -A umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted."
@@ -14,9 +14,9 @@ unmountusb() {
1414
1515 drives=$(lsblk -nrpo "name,type,size,mountpoint,label" | awk -F':' '{gsub(/ /,":")}$4!~/\/boot|\/efi|\/home$|SWAP/&&length($4)>1{printf "%s (%s) %s\n",$4,$3,$5}')
1616
17−if [ -z "$drives" ]; then
17+if [ -z "$drives" ]; then
1818 echo "No drives to unmount." && exit
1919 else
2020 echo "Unmountable USB drive detected."
21− unmountusb
21+ unmountusb
2222 fi