summaryrefslogtreecommitdiff
path: root/mounter.sh
blob: 98f0c130ab6d16c4e96ab9284d7b3ab0111ea3ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh

# Get list of possible partitions to mount. Only select partitions that have
# not been mounted and display their name and size as dmenu options.
parts=$(
    lsblk -nlpo NAME,SIZE,TYPE,MOUNTPOINT | grep "part $" | cut -f 1,4 -d' '
)
[[ -z $parts ]] && exit 1

# Prompt for partition to mount.
choice=$(
    echo "$parts" | dmenu -i -p "Mount which partition?" | cut -f 1 -d' '
)
[[ -z $choice ]] && exit 1

# Create a mount directory if none exists. Use UUID for unique name.
mntdir="/mnt/$(lsblk -n "$choice" -o UUID | cut -f 1 -d' ')"
sudo mkdir -p "$mntdir"
sudo mount "$choice" "$mntdir"