summaryrefslogtreecommitdiff
path: root/.local/bin/dmenu/mount-device
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/dmenu/mount-device')
-rwxr-xr-x.local/bin/dmenu/mount-device24
1 files changed, 18 insertions, 6 deletions
diff --git a/.local/bin/dmenu/mount-device b/.local/bin/dmenu/mount-device
index e325a65..c2decd5 100755
--- a/.local/bin/dmenu/mount-device
+++ b/.local/bin/dmenu/mount-device
@@ -2,16 +2,22 @@
2# Script for mounting block devices 2# Script for mounting block devices
3 3
4# Set askpass program for authentication 4# Set askpass program for authentication
5export SUDO_ASKPASS=/usr/bin/ssh-askpass 5#export SUDO_ASKPASS=/usr/bin/ssh-askpass
6 6
7# Check for and get device to mount from user 7# Check for and get device to mount from user
8devs="$(lsblk -lp | grep "part $" | awk '{print $1,"-",$4}')" 8devs="$(lsblk -lpo NAME,FSTYPE,SIZE,TYPE,MOUNTPOINT | grep "part\s*$\|crypto_LUKS" | awk '{print $1,"-",$3}')"
9[ "$devs" = "" ] && exit 0 9[ "$devs" = "" ] && exit 0
10dev="$(echo $devs | dmenu -i -p "Select device" | cut -d ' ' -f 1)" 10dev="$(echo "$devs" | dmenu -i -p "Select device" | cut -d ' ' -f 1)"
11[ "$dev" = "" ] && exit 0 11[ "$dev" = "" ] && exit 0
12 12
13# Open and map drive if it is encrypted
14crypt=0
15[ "$(lsblk -no FSTYPE $dev)" = "crypto_LUKS" ] && crypt=1 && \
16 mapname="$(echo -n "" | dmenu -i -p "Enter device mapper name")" && \
17 sudo cryptsetup open $dev $mapname
18
13# Attempt to mount without mountpoint for devices in /etc/fstab 19# Attempt to mount without mountpoint for devices in /etc/fstab
14sudo -A mount "$dev" 2>/dev/null && exit 0 20sudo mount "$dev" 2>/dev/null && exit 0
15 21
16# Get mountpoint from user 22# Get mountpoint from user
17mntpnt="$(find /mnt -maxdepth 3 -type d 2>/dev/null | dmenu -i -p "Select mountpoint")" 23mntpnt="$(find /mnt -maxdepth 3 -type d 2>/dev/null | dmenu -i -p "Select mountpoint")"
@@ -23,5 +29,11 @@ mntpnt="$(find /mnt -maxdepth 3 -type d 2>/dev/null | dmenu -i -p "Select mountp
23 dmenu -i -p "$mntpnt does not exist, would you like to create it?")" && \ 29 dmenu -i -p "$mntpnt does not exist, would you like to create it?")" && \
24 ([ "$create" = "Yes" ] && sudo -A mkdir -p $mntpnt || exit 0) 30 ([ "$create" = "Yes" ] && sudo -A mkdir -p $mntpnt || exit 0)
25 31
26sudo -A mount $dev $mntpnt && pgrep -x dunst && notify-send "$dev mounted to $mntpnt" 32# Mount the device
27 33if [ $crypt -eq 1 ]; then
34 sudo -A mount /dev/mapper/$mapname $mntpnt && pgrep -x dunst && \
35 notify-send "$dev mounted to $mntpnt"
36else
37 sudo -A mount $dev $mntpnt && pgrep -x dunst && \
38 notify-send "$dev mounted to $mntpnt"
39fi