diff options
Diffstat (limited to '.local/bin/dmenu')
-rwxr-xr-x | .local/bin/dmenu/mount-device | 39 | ||||
-rwxr-xr-x | .local/bin/dmenu/unicode-select | 9 | ||||
-rwxr-xr-x | .local/bin/dmenu/unmount-device | 28 |
3 files changed, 0 insertions, 76 deletions
diff --git a/.local/bin/dmenu/mount-device b/.local/bin/dmenu/mount-device deleted file mode 100755 index c2decd5..0000000 --- a/.local/bin/dmenu/mount-device +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | # Script for mounting block devices | ||
3 | |||
4 | # Set askpass program for authentication | ||
5 | #export SUDO_ASKPASS=/usr/bin/ssh-askpass | ||
6 | |||
7 | # Check for and get device to mount from user | ||
8 | devs="$(lsblk -lpo NAME,FSTYPE,SIZE,TYPE,MOUNTPOINT | grep "part\s*$\|crypto_LUKS" | awk '{print $1,"-",$3}')" | ||
9 | [ "$devs" = "" ] && exit 0 | ||
10 | dev="$(echo "$devs" | dmenu -i -p "Select device" | cut -d ' ' -f 1)" | ||
11 | [ "$dev" = "" ] && exit 0 | ||
12 | |||
13 | # Open and map drive if it is encrypted | ||
14 | crypt=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 | |||
19 | # Attempt to mount without mountpoint for devices in /etc/fstab | ||
20 | sudo mount "$dev" 2>/dev/null && exit 0 | ||
21 | |||
22 | # Get mountpoint from user | ||
23 | mntpnt="$(find /mnt -maxdepth 3 -type d 2>/dev/null | dmenu -i -p "Select mountpoint")" | ||
24 | [ "$mntpnt" = "" ] && exit 1 | ||
25 | |||
26 | # If selected mountpoint does not exist ask to create it | ||
27 | # If user decides not to create non-existent drive, exit | ||
28 | [ ! -d $mntpnt ] && create="$(echo "No\nYes" | \ | ||
29 | dmenu -i -p "$mntpnt does not exist, would you like to create it?")" && \ | ||
30 | ([ "$create" = "Yes" ] && sudo -A mkdir -p $mntpnt || exit 0) | ||
31 | |||
32 | # Mount the device | ||
33 | if [ $crypt -eq 1 ]; then | ||
34 | sudo -A mount /dev/mapper/$mapname $mntpnt && pgrep -x dunst && \ | ||
35 | notify-send "$dev mounted to $mntpnt" | ||
36 | else | ||
37 | sudo -A mount $dev $mntpnt && pgrep -x dunst && \ | ||
38 | notify-send "$dev mounted to $mntpnt" | ||
39 | fi | ||
diff --git a/.local/bin/dmenu/unicode-select b/.local/bin/dmenu/unicode-select deleted file mode 100755 index b797691..0000000 --- a/.local/bin/dmenu/unicode-select +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | # Select unicode character via dmenu and copy to clipboard | ||
3 | |||
4 | line="$(cat ~/.local/share/unicode_list | dmenu -i -l 10)" | ||
5 | grep "$line" ~/.local/share/unicode_list | tr -d [:print:] | | ||
6 | xclip -r -selection "clipboard" && | ||
7 | notify-send "$(xclip -selection "clipboard" -o) copied to clipboard" | ||
8 | |||
9 | |||
diff --git a/.local/bin/dmenu/unmount-device b/.local/bin/dmenu/unmount-device deleted file mode 100755 index 239663d..0000000 --- a/.local/bin/dmenu/unmount-device +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | # Script for unmounting filesystems | ||
3 | |||
4 | # Set askpass program for authentication | ||
5 | #export SUDO_ASKPASS=/usr/bin/ssh-askpass | ||
6 | |||
7 | # Get list of unmountable filesystems excluding critical ones (/, /home, /boot, etc...) | ||
8 | exclude="\(/\|/boot\|/boot/efi\|/var\|/tmp\|/home\)$" | ||
9 | parts="$(lsblk -lp | grep "\(part\|crypt\)\s*/" | grep -v "$exclude" | awk '{print $7,"-",$4}')" | ||
10 | [ "$parts" = "" ] && exit 0 | ||
11 | |||
12 | # Get filesystem to unmount from user | ||
13 | crypt=0 | ||
14 | select="$(echo "$parts" | dmenu -i -p "Select filesystem to unmount" | cut -d ' ' -f 1)" | ||
15 | [ "$select" = "" ] && exit 0 | ||
16 | dev="$(lsblk -lp | grep "$select" | awk '{print $1}')" | ||
17 | [ "$(lsblk -no TYPE $dev)" = "crypt" ] && crypt=1 | ||
18 | |||
19 | # Unmount the filesystem | ||
20 | umount=0 | ||
21 | sudo umount $select && pgrep -x dunst && \ | ||
22 | notify-send "Unmounted $select ($dev)" && umount=1 \ | ||
23 | || notify-send "Error: unable to unmount $select" "Are you in it?" | ||
24 | |||
25 | [ $crypt -eq 1 -a $umount -eq 1 ] && sudo cryptsetup close $dev && pgrep -x dunst && \ | ||
26 | notify-send "Unmapped $dev" && exit 14 | ||
27 | |||
28 | |||