From b49fbd12bd77f379fc1bf466531dec20658f7540 Mon Sep 17 00:00:00 2001 From: zachir Date: Sun, 6 Aug 2023 22:55:00 -0500 Subject: Fully replace bemenu with tofi --- dmount | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'dmount') diff --git a/dmount b/dmount index 0aeb89f..bbfd587 100755 --- a/dmount +++ b/dmount @@ -14,9 +14,7 @@ error_msg () { exit 1 } -while getopts "xwhpPugd:" o; do case "${o}" in - x) DMENU="dmenu" ;; - w) DMENU="bemenu" ;; +while getopts "hpPugd:" o; do case "${o}" in d) ARGS="$ARGS $OPTARG" ;; p) USE_USER_ID="y" ;; P) unset USE_USER_ID ;; @@ -31,19 +29,19 @@ while getopts "xwhpPugd:" o; do case "${o}" in exit 1;; esac done -if [ -z "$DMENU" ]; then - if [ -n "$WAYLAND_DISPLAY" ]; then - DMENU="bemenu" - elif [ -n "$DISPLAY" ]; then - DMENU="dmenu" - else - error_msg "Can't tell if Wayland or Xorg; is there a display server?" - fi +if [ -n "$WAYLAND_DISPLAY" ]; then + DMENU="tofi" + DEFARGS="-c $HOME/.config/tofi/themes/dmenu_vertical --prompt-text" +elif [ -n "$DISPLAY" ]; then + DMENU="dmenu" + DEFARGS="-l 10 -p" +else + error_msg "Can't tell if Wayland or Xorg; is there a display server?" fi case "$DMENU" in dmenu) PASSARG="-P" ;; - bemenu) PASSARG="-x" ;; + tofi) PASSARG="--hide-input=true" ;; esac check_crypto () { @@ -55,8 +53,8 @@ is_crypto () { } unlock_crypto () { - NAME="$(cat /dev/null | $DMENU -p "Name" $ARGS)" - PASSWORD="$(cat /dev/null | $DMENU -p "Password" $PASSARG $ARGS)" + NAME="$(cat /dev/null | $DMENU $DEFARGS "Name" $ARGS)" + PASSWORD="$(cat /dev/null | $DMENU $DEFARGS "Password" $PASSARG $ARGS)" echo "$PASSWORD" | sudo cryptsetup open "$1" "$NAME" || FAILED="y" unset PASSWORD [ -n "$FAILED" ] && \ @@ -79,11 +77,11 @@ get_available () { lsblk -oPATH,FSTYPE,MOUNTPOINT | tail -n+2 | while read i; do getmount() { \ [ -z "$chosen" ] && exit 1 # shellcheck disable=SC2086 - mp="$(find $1 2>/dev/null | $DMENU -l 10 $ARGS -p "Type in mount point.")" || error_msg "Canceled; no mount point chosen." + mp="$(find $1 2>/dev/null | $DMENU $ARGS $DEFARGS "Type in mount point.")" || error_msg "Canceled; no mount point chosen." test -z "$mp" && \ exit 1 if [ ! -d "$mp" ]; then - mkdiryn=$(printf "No\\nYes" | $DMENU -l 10 $ARGS -p "$mp does not exist. Create it?") || \ + mkdiryn=$(printf "No\\nYes" | $DMENU $ARGS $DEFARGS "$mp does not exist. Create it?") || \ exit 1 [ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || doas mkdir -p "$mp") fi @@ -107,15 +105,15 @@ mount_device () { fi } -DEVICE="$(get_available | $DMENU -p "Devices" $ARGS -l 15)" +DEVICE="$(get_available | $DMENU $DEFARGS "Devices" $ARGS )" [ -z "$DEVICE" ] && exit 1 chosen="${DEVICE%% *}" if [ -n "$(is_crypto "$chosen")" ]; then unlock_crypto "$chosen" - unset DEVICE chosen DMENU ARGS PASSARG + unset DEVICE chosen DMENU DEFARGS ARGS PASSARG dmount fi mount_device "$chosen" -unset DEVICE chosen DMENU ARGS PASSARG +unset DEVICE chosen DMENU DEFARGS ARGS PASSARG -- cgit v1.2.3