diff options
| author | subh <subh@subh.space> | 2026-04-03 14:47:03 +0530 |
|---|---|---|
| committer | subh <subh@subh.space> | 2026-04-03 14:47:03 +0530 |
| commit | 314d760de1922128124f2a9be0494fd4f6f7effb (patch) | |
| tree | 3f4bb374fc89be2b1cd4e2a0a21ae17d4bf83452 /scripts/umount-usb.sh | |
| parent | 0203dd4b8d45c663356f797c11be17fdec6f22f2 (diff) | |
new music bar, auto usb mounting and more
Diffstat (limited to 'scripts/umount-usb.sh')
| -rwxr-xr-x | scripts/umount-usb.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/scripts/umount-usb.sh b/scripts/umount-usb.sh new file mode 100755 index 0000000..e745ef2 --- /dev/null +++ b/scripts/umount-usb.sh @@ -0,0 +1,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." |
