use rofi for mounter, unmounter
This commit is contained in:
parent
e6a46d699b
commit
32b1abc39f
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Gives a dmenu prompt to mount unmounted drives. If
|
# Gives a rofi -dmenu prompt to mount unmounted drives. If
|
||||||
# they're in /etc/fstab, they'll be mounted automatically. Otherwise, you'll
|
# they're in /etc/fstab, they'll be mounted automatically. Otherwise, you'll
|
||||||
# be prompted to give a mountpoint from already existsing directories. If you
|
# be prompted to give a mountpoint from already existsing directories. If you
|
||||||
# input a novel directory, it will prompt you to create that directory.
|
# input a novel directory, it will prompt you to create that directory.
|
||||||
|
|
@ -8,16 +8,16 @@
|
||||||
getmount() { \
|
getmount() { \
|
||||||
[ -z "$chosen" ] && exit 1
|
[ -z "$chosen" ] && exit 1
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")" || exit 1
|
mp="$(find $1 2>/dev/null | rofi -dmenu -i -p "Type in mount point.")" || exit 1
|
||||||
test -z "$mp" && exit 1
|
test -z "$mp" && exit 1
|
||||||
if [ ! -d "$mp" ]; then
|
if [ ! -d "$mp" ]; then
|
||||||
mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") || exit 1
|
mkdiryn=$(printf "No\\nYes" | rofi -dmenu -i -p "$mp does not exist. Create it?") || exit 1
|
||||||
[ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp")
|
[ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp")
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
mountusb() { \
|
mountusb() { \
|
||||||
chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?")" || exit 1
|
chosen="$(echo "$usbdrives" | rofi -dmenu -i -p "Mount which drive?")" || exit 1
|
||||||
chosen="$(echo "$chosen" | awk '{print $1}')"
|
chosen="$(echo "$chosen" | awk '{print $1}')"
|
||||||
sudo -A mount "$chosen" 2>/dev/null && notify-send "💻 USB mounting" "$chosen mounted." && exit 0
|
sudo -A mount "$chosen" 2>/dev/null && notify-send "💻 USB mounting" "$chosen mounted." && exit 0
|
||||||
alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not ( -path *%s -prune ) ",$3}')
|
alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not ( -path *%s -prune ) ",$3}')
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# A dmenu prompt to unmount drives.
|
# A rofi -dmenu prompt to unmount drives.
|
||||||
# Provides you with mounted partitions, select one to unmount.
|
# Provides you with mounted partitions, select one to unmount.
|
||||||
# Drives mounted at /, /boot and /home will not be options to unmount.
|
# Drives mounted at /, /boot and /home will not be options to unmount.
|
||||||
|
|
||||||
unmountusb() {
|
unmountusb() {
|
||||||
[ -z "$drives" ] && exit
|
[ -z "$drives" ] && exit
|
||||||
chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1
|
chosen="$(echo "$drives" | rofi -dmenu -i -p "Unmount which drive?")" || exit 1
|
||||||
chosen="$(echo "$chosen" | awk '{print $1}')"
|
chosen="$(echo "$chosen" | awk '{print $1}')"
|
||||||
[ -z "$chosen" ] && exit
|
[ -z "$chosen" ] && exit
|
||||||
sudo -A umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted."
|
sudo -A umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted."
|
||||||
|
|
@ -14,9 +14,9 @@ unmountusb() {
|
||||||
|
|
||||||
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}')
|
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}')
|
||||||
|
|
||||||
if [ -z "$drives" ]; then
|
if [ -z "$drives" ]; then
|
||||||
echo "No drives to unmount." && exit
|
echo "No drives to unmount." && exit
|
||||||
else
|
else
|
||||||
echo "Unmountable USB drive detected."
|
echo "Unmountable USB drive detected."
|
||||||
unmountusb
|
unmountusb
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue