diff --git a/.scripts/i3cmds/dmenumount b/.scripts/i3cmds/dmenumount index 0f085d3a..6fd466e1 100755 --- a/.scripts/i3cmds/dmenumount +++ b/.scripts/i3cmds/dmenumount @@ -16,11 +16,11 @@ getmount() { \ } mountusb() { \ - keys=$(echo -e $usbdrives | awk '/name/{ if ($6 != "null") printf "%s (%s)\\n", $6, $4; else printf "%s (%s)\\n", $2, $4; }') - map=$(echo -e $usbdrives | awk '/name/{ if ($6 != "null") printf "[\"%s\"]=%s\n", $6, $2; else printf "[\"%s\"]=%s\n", $2, $2; }') + keys=$(echo -e "$usbdrives" | awk '{ printf "%s (%s)\\n", $2 != "null" ? $2 : $1, $3; }') + hmap=$(echo -e "$usbdrives" | awk '{ printf "[\"%s\"]=%s\n", $2 != "null" ? $2 : $1, $1; }') device="$(echo -e "$keys" | sort -r | dmenu -i -p "Mount which drive?" | awk '{print $1}')" - eval declare -A devices=($map) + eval declare -A devices=($hmap) chosen=${devices["$device"]} sudo -A mount "$chosen" && notify-send -i "$PIX/usb.svg" "$chosen mounted." && exit 0 @@ -48,7 +48,9 @@ asktype() { \ } anddrives=$(simple-mtpfs -l 2>/dev/null) -usbdrives=$(lsblk -Jplf -o name,size,label,type,mountpoint | tr -d " \"{}" | sed 's/:\|,/ /g' | awk /name/'{ if ($NF == "null" && $8 == "part") printf "%s\\n", $0; }') +usbdrives=$(lsblk -Jplf -o name,label,size,type,mountpoint | tr -d " \"{}" | sed 's/:\|,/ /g' | awk '/name/ && $NF=="null" && $8=="part"{print $2, $4, $6; }') + +echo "$usbdrives" if [ -z "$usbdrives" ]; then [ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit diff --git a/.scripts/i3cmds/dmenuumount b/.scripts/i3cmds/dmenuumount index 8eb0901b..26fb556e 100755 --- a/.scripts/i3cmds/dmenuumount +++ b/.scripts/i3cmds/dmenuumount @@ -6,11 +6,11 @@ unmountusb() { [ -z "$drives" ] && exit - keys=$(echo -e $drives | awk '/name/{ if ($6 != "null") printf "%s (%s)\\n", $6, $4; else printf "%s (%s)\\n", $2, $4; }') - map=$(echo -e $drives | awk '/name/{ if ($6 != "null") printf "[\"%s\"]=%s\n", $6, $2; else printf "[\"%s\"]=%s\n", $2, $2; }') + keys=$(echo -e "$drives" | awk '{ printf "%s (%s)\n", $2 != "null" ? $2 : $1, $3; }') + hmap=$(echo -e "$drives" | awk '{ printf "[\"%s\"]=%s\n", $2 != "null" ? $2 : $1, $1; }') chosen="$(echo -e "$keys" | sort -r | dmenu -i -p "Unmount which drive?" | awk '{print $1}')" - eval declare -A devices=($map) + eval declare -A devices=($hmap) mp=${devices["$chosen"]} [ -z "$chosen" ] && exit @@ -30,7 +30,7 @@ asktype() { \ esac } -drives=$(lsblk -Jplf -o name,size,label,type,mountpoint | tr -d " \"{}" | sed 's/:\|,/ /g' | awk /name/'{ if ($NF != "null" && $NF !~/\/boot|\/home$|SWAP/&&length($NF)>1 && $8 == "part") printf "%s\\n", $0; }') +drives=$(lsblk -Jplf -o name,label,size,type,mountpoint | tr -d " \"{}" | sed 's/:\|,/ /g' | awk '/name/ && $NF != "null" && $NF !~/\/boot|\/home$|SWAP/&&length($NF)>1 && $8=="part" {print $2, $4, $6;}') if ! grep simple-mtpfs /etc/mtab; then [ -z "$drives" ] && echo "No drives to unmount." && exit