summaryrefslogtreecommitdiff
path: root/dmenu
diff options
context:
space:
mode:
Diffstat (limited to 'dmenu')
-rwxr-xr-xdmenu37
1 files changed, 37 insertions, 0 deletions
diff --git a/dmenu b/dmenu
new file mode 100755
index 0000000..1a54458
--- /dev/null
+++ b/dmenu
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+TOFI_CONF="$XDG_CONFIG_HOME/tofi/themes/dmenu"
+if [ -n "$WAYLAND_DISPLAY" ]; then
+ if echo "$@" | grep -qE -- '-l [0-9]+'; then
+ declare -a ARGS
+ SKIP="0"
+ for arg in "$@"; do
+ echo "$arg" | grep -qE '^\s*-l\s*' && SKIP=2
+ if [ "$SKIP" -gt 0 ]; then
+ DMENULINES="y"
+ TOFI_CONF="$XDG_CONFIG_HOME/tofi/themes/dmenu_vertical"
+ SKIP="$((SKIP - 1))"
+ continue
+ fi
+ if echo "$arg" | grep -qE '.* .*'; then
+ ARGS+=("$arg")
+ else
+ ARGS+=("$arg")
+ fi
+ done
+ fi
+fi
+
+if [ -n "$WAYLAND_DISPLAY" ]; then
+ # Wayland
+ if [ -n "$DMENULINES" ]; then
+ tofi -c "$TOFI_CONF" -d "${ARGS[@]}"
+ else
+ tofi -c "$TOFI_CONF" -d "$@" 2>/dev/null
+ fi
+ unset ARGS
+elif [ -n "$DISPLAY" ]; then
+ # X11
+ dmenu $@
+fi
+unset TOFI_CONF