diff options
author | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2023-06-17 06:23:12 +0300 |
---|---|---|
committer | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2023-06-17 06:23:12 +0300 |
commit | 4a50101176ee69a08a47f8a912505dc0af310b62 (patch) | |
tree | beb1a22a5a1a8d7ba3ccc1b57da0b2908a1504af /dotfiles/.local/bin/menublk | |
parent | 4fc7fc724a14dd5dd12f4f5c7d6d18eb0c75fd63 (diff) | |
download | swayrice-4a50101176ee69a08a47f8a912505dc0af310b62.tar.gz swayrice-4a50101176ee69a08a47f8a912505dc0af310b62.zip |
menublk: fixes and improvements
* Use udevadm instead of lsblk for fs type info.
* Fix some USB drives not appearing the poweroff menu.
Diffstat (limited to 'dotfiles/.local/bin/menublk')
-rwxr-xr-x | dotfiles/.local/bin/menublk | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/dotfiles/.local/bin/menublk b/dotfiles/.local/bin/menublk index 64d28fd..ec5bca5 100755 --- a/dotfiles/.local/bin/menublk +++ b/dotfiles/.local/bin/menublk @@ -54,31 +54,31 @@ get_unmountable() { } mount_dev() { - fstype="$(lsblk -r -o FSTYPE "/dev/$1" | tail -n 1)" + fstype="$(udevadm info -x /dev/sdd1 | grep FS_TYPE | cut -d '=' -f2)" part="/dev/$1" if [ "$fstype" = "crypto_LUKS" ]; then password="$(echo "" | rofi -dmenu -password -p "Enter passphrase for encrypted drive" --tf="$BEMENU_TF" --tb="$BEMENU_NB" --ff="$BEMENU_NB" --fb="$BEMENU_NB" --fn="$BEMENU_FN" --nb="$BEMENU_NB" --nf="$BEMENU_NF" --hf="$BEMENU_HF" --hb="$BEMENU_HB" --monitor="$BEMENU_MONITOR")" if [ -z "$password" ]; then exit 0 fi - printf "%s" "$password" > "$HOME/.cache/diskey" + echo -n "$password" > "$HOME/.cache/diskey" part="$(udisksctl unlock --key-file="$HOME/.cache/diskey" -b "/dev/$1" 2> $HOME/.cache/udiskerr | cut -d " " -f4 )" part="${part%?}" rm -f "$HOME/.cache/diskey" - if [ $? -ne 0 ]; then - notify_and_end "Error mounting: $(cat $HOME/.cache/udiskerr)" 1 + if [ $? -ne 0 -o -z "$part" ]; then + notify_and_end "$(cat $HOME/.cache/udiskerr)" 1 fi fi message="$(udisksctl mount -b "$part" 2> $HOME/.cache/udiskerr)" if [ $? -eq 0 ]; then notify_and_end "$message" 0 else - notify_and_end "Error mounting: $(cat $HOME/.cache/udiskerr)" 1 + notify_and_end "Error mounting $part: $(cat $HOME/.cache/udiskerr)" 1 fi } unmount_dev() { - fstype="$(lsblk -r -o FSTYPE "/dev/$1" | sed "2q;d")" + fstype="$(udevadm info -x /dev/sdd1 | grep FS_TYPE | cut -d '=' -f2)" if [ "$fstype" = "crypto_LUKS" ]; then volume="/dev/mapper/$(lsblk -r -o NAME "/dev/$1" | tail -n 1)" if udisksctl unmount -b "$volume" 2> $HOME/.cache/udiskerr && udisksctl lock -b "/dev/$1" 2> $HOME/.cache/udiskerr; then @@ -97,7 +97,7 @@ unmount_dev() { get_usb_storage() { for dev in /sys/block/*; do - if udevadm info --query=property --path=$dev | grep -q ^ID_BUS=usb; then + if udevadm info --query=property --path=$dev | grep -q USB; then echo "$(cut -d "/" -f4 <<< ${dev})" fi done |