blob: e745ef2fa82f1c30b8a64fd0c7423681d13a235f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/bin/bash
set -e
lsblkoutput="$(lsblk -nrpo "name,type,size,mountpoint")"
mounteddrives="$(echo "$lsblkoutput" | awk '($2=="part"||$2="crypt")&&$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')"
allunmountable="$(echo "$mounteddrives" | sed "/^$/d;s/ *$//")"
test -n "$allunmountable"
chosen="$(echo "$allunmountable" | rofi -dmenu -p "Unmount which drive?")"
chosen="${chosen%% *}"
test -n "$chosen"
sudo umount -l "/${chosen#*/}"
notify-send "💾 Device unmounted." "$chosen has been unmounted"
cryptid="$(echo "$lsblkoutput" | grep "/${chosen#*/}$")"
cryptid="${cryptid%% *}"
test -b /dev/mapper/"${cryptid##*/}"
sudo cryptsetup close "$cryptid"
notify-send "🔒 Device dencryption closed." "Drive is now securely locked again."
|