blob: 75cb10f86bee9f1636597805025e19c1653eacb3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#!/bin/sh
# Script for unmounting filesystems
# Set askpass program for authentication
export SUDO_ASKPASS=/usr/bin/ssh-askpass
# Get list of unmountable filesystems excluding critical ones (/, /home, /boot, etc...)
exclude="\(/\|/boot\|/boot/efi\|/var\|/tmp\|/home\)$"
parts="$(lsblk -lp | grep "part /" | grep -v "$exclude" | awk '{print $7,"-",$4}')"
[ "$parts" = "" ] && exit 0
# Get filesystem to unmount from user
select="$(echo "$parts" | dmenu -i -p "Select filesystem to unmount" | cut -d ' ' -f 1)"
[ "$select" = "" ] && exit 0
dev="$(lsblk -lp | grep "$select" | awk '{print $1}')"
# Unmount the filesystem
sudo -A umount $select && pgrep -x dunst && notify-send "Unmounted $select ($dev)" \
|| notify-send "Error: unable to unmount $select" "Are you in it?"
|