summaryrefslogtreecommitdiff
path: root/dmenumount
diff options
context:
space:
mode:
authorzachir <zachir@librem.one>2023-02-27 00:21:09 -0600
committerzachir <zachir@librem.one>2023-02-27 00:21:09 -0600
commit187a18feb73ac9a1513a6100a1ffdb5f29f3debe (patch)
treeecbb010c74cc97035c1c091003a4937355d3a01f /dmenumount
parent7a1beb8c5d4ce12dd7ede3c4407617f0e81f5a43 (diff)
change dmenu books, mount/umount, unicode to use bemenu and not need -w -x flag
Diffstat (limited to 'dmenumount')
-rwxr-xr-xdmenumount25
1 files changed, 18 insertions, 7 deletions
diff --git a/dmenumount b/dmenumount
index 91b0827..b37f139 100755
--- a/dmenumount
+++ b/dmenumount
@@ -10,25 +10,36 @@ printhelp () {
}
while getopts "wxhd:" o; do case "${o}" in
- w) DMENU="tofi" ;;
+ w) DMENU="bemenu" ;;
x) DMENU="dmenu" ;;
d) ARGS="$ARGS$OPTARG " ;;
*) printhelp ;;
esac done
+if [ -z "$DMENU" ]; then
+ if [ -n "$WAYLAND_DISPLAY" ]; then
+ DMENU="bemenu"
+ elif [ -n "$DISPLAY" ]; then
+ DMENU="dmene"
+ else
+ print "Can't tell if Wayland or X; what gives?\n"
+ exit 1
+ fi
+fi
+
getmount() { \
[ -z "$chosen" ] && exit 1
# shellcheck disable=SC2086
- mp="$(find $1 2>/dev/null | $DMENU $ARGS -p "Type in mount point.")" || exit 1
+ mp="$(find $1 2>/dev/null | $DMENU -l 10 $ARGS -p "Type in mount point.")" || exit 1
test -z "$mp" && exit 1
if [ ! -d "$mp" ]; then
- mkdiryn=$(printf "No\\nYes" | $DMENU $ARGS -p "$mp does not exist. Create it?") || exit 1
+ mkdiryn=$(printf "No\\nYes" | $DMENU -l 10 $ARGS -p "$mp does not exist. Create it?") || exit 1
[ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || doas mkdir -p "$mp")
fi
}
mountusb() { \
- chosen="$(echo "$usbdrives" | $DMENU $ARGS -p "Mount which drive?")" || exit 1
+ chosen="$(echo "$usbdrives" | $DMENU -l 10 $ARGS -p "Mount which drive?")" || exit 1
chosen="$(echo "$chosen" | awk '{print $1}')"
echo "$chosen"
doas mount "$chosen" 2>/dev/null && notify-send "💻 USB mounting" "$chosen mounted." && exit 0
@@ -44,17 +55,17 @@ mountusb() { \
}
mountandroid() { \
- chosen="$(echo "$anddrives" | $DMENU $ARGS -p "Which Android device?")" || exit 1
+ chosen="$(echo "$anddrives" | $DMENU -l 10 $ARGS -p "Which Android device?")" || exit 1
chosen="$(echo "$chosen" | cut -d : -f 1)"
getmount "$HOME -maxdepth 3 -type d"
simple-mtpfs --device "$chosen" "$mp"
- echo "OK" | $DMENU $ARGS -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1
+ echo "OK" | $DMENU -l 10 $ARGS -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1
simple-mtpfs --device "$chosen" "$mp"
notify-send "🤖 Android Mounting" "Android device mounted to $mp."
}
asktype() { \
- choice="$(printf "USB\\nAndroid" | $DMENU $ARGS -p "Mount a USB drive or Android device?")" || exit 1
+ choice="$(printf "USB\\nAndroid" | $DMENU -l 10 $ARGS -p "Mount a USB drive or Android device?")" || exit 1
case $choice in
USB) mountusb ;;
Android) mountandroid ;;