#!/bin/sh set -e [ -n "$DEBUG" ] && set -x # make sure there we are the only running menu pgrep bemenu >/dev/null && pkill -f bemenu # always source the config to make sure . "$HOME"/.config/bemenu.conf arg0=bemenu MENU_PROMPT=${MENU_PROMPT:-} MENU_FROM_PATH=${MENU_FROM_PATH:-} # this is used by -run to combine desktop files and PATH binaries if [ -n "$MENU_FROM_PATH" ]; then (cat ; (fd -tf -tl -tx . $(printf "%s" "$PATH" | tr : ' ') -x printf "%s\n" {/} | sort -u)) | env -u MENU_FROM_PATH $0 exit $? fi idx=0 while test $# -gt $idx; do case "$1" in -run) # arg0=bemenu-run export MENU_FROM_PATH=1 # reexec arg0="j4-dmenu-desktop --no-generic --dmenu=$0 --term=foot" shift ;; -drun) arg0="j4-dmenu-desktop --no-generic --dmenu=$0 --term=foot" shift ;; -p) shift MENU_PROMPT="$1" shift ;; -x) shift BEMENU_OPTS="${BEMENU_OPTS} --password" ;; esac idx=$((idx + 1)) done if [ -n "${MENU_POPUP}" ]; then BEMENU_OPTS="${BEMENU_OPTS} --center --width-factor 0.5 --border 2 --list 8" # --fixed-height fi BEMENU_OPTS="${BEMENU_OPTS} --prompt \"${MENU_PROMPT}\"" BEMENU_OPTS="${BEMENU_OPTS} $*" exec ${arg0}