dotfiles-x1132b1abc
use rofi for mounter, unmounter
+8 −8
2 files changed
- M .local/bin/mounter +4 −4
- M .local/bin/unmounter +4 −4
| @@ -1,6 +1,6 @@ | |||
| 1 | 1 | #!/bin/sh | |
| 2 | 2 | ||
| 3 | − | # Gives a dmenu prompt to mount unmounted drives. If | |
| 3 | + | # Gives a rofi -dmenu prompt to mount unmounted drives. If | |
| 4 | 4 | # they're in /etc/fstab, they'll be mounted automatically. Otherwise, you'll | |
| 5 | 5 | # be prompted to give a mountpoint from already existsing directories. If you | |
| 6 | 6 | # input a novel directory, it will prompt you to create that directory. | |
| @@ -8,16 +8,16 @@ | |||
| 8 | 8 | getmount() { \ | |
| 9 | 9 | [ -z "$chosen" ] && exit 1 | |
| 10 | 10 | # 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 | |
| 12 | 12 | test -z "$mp" && exit 1 | |
| 13 | 13 | 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 | |
| 15 | 15 | [ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp") | |
| 16 | 16 | fi | |
| 17 | 17 | } | |
| 18 | 18 | ||
| 19 | 19 | 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 | |
| 21 | 21 | chosen="$(echo "$chosen" | awk '{print $1}')" | |
| 22 | 22 | sudo -A mount "$chosen" 2>/dev/null && notify-send "💻 USB mounting" "$chosen mounted." && exit 0 | |
| 23 | 23 | alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not ( -path *%s -prune ) ",$3}') | |
| @@ -1,12 +1,12 @@ | |||
| 1 | 1 | #!/bin/sh | |
| 2 | 2 | ||
| 3 | − | # A dmenu prompt to unmount drives. | |
| 3 | + | # A rofi -dmenu prompt to unmount drives. | |
| 4 | 4 | # Provides you with mounted partitions, select one to unmount. | |
| 5 | 5 | # Drives mounted at /, /boot and /home will not be options to unmount. | |
| 6 | 6 | ||
| 7 | 7 | unmountusb() { | |
| 8 | 8 | [ -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 | |
| 10 | 10 | chosen="$(echo "$chosen" | awk '{print $1}')" | |
| 11 | 11 | [ -z "$chosen" ] && exit | |
| 12 | 12 | sudo -A umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted." | |
| @@ -14,9 +14,9 @@ unmountusb() { | |||
| 14 | 14 | ||
| 15 | 15 | 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}') | |
| 16 | 16 | ||
| 17 | − | if [ -z "$drives" ]; then | |
| 17 | + | if [ -z "$drives" ]; then | |
| 18 | 18 | echo "No drives to unmount." && exit | |
| 19 | 19 | else | |
| 20 | 20 | echo "Unmountable USB drive detected." | |
| 21 | − | unmountusb | |
| 21 | + | unmountusb | |
| 22 | 22 | fi | |