diff options
Diffstat (limited to 'bin/menu')
| -rwxr-xr-x | bin/menu | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/bin/menu b/bin/menu index f40e762..23e7801 100755 --- a/bin/menu +++ b/bin/menu @@ -2,10 +2,14 @@ set -e [ -n "$DEBUG" ] && set -x +# make sure there we are the only running menu +pgrep -x bemenu >/dev/null && killall -INT bemenu + +# always source the config to make sure +. "$HOME"/.config/bemenu.conf + arg0=bemenu -# prompt=${MENU_PROMPT:- :} prompt=${MENU_PROMPT:-} -main_color="#4E4371" args= idx=0 @@ -13,15 +17,37 @@ while test $# -gt $idx; do case "$1" in -run) arg0=bemenu-run - prompt=" " + prompt="" shift ;; -drun) - # arg0=$HOME/devel/upstream/github.com/Cloudef/bemenu/bemenu-drun; prompt=bin - arg0=bemenu-drun - prompt=" " - main_color="#e03c8a" + # arg0=bemenu-drun + # prompt="" shift + desktopfiles() { + fd -e desktop . \ + /usr/share/applications/ \ + /usr/local/share/applications/ \ + /var/lib/flatpak/app/*/current/active/export/share/applications/ \ + "$XDG_DATA_HOME"/applications/ 2>/dev/null || true + } + list_apps() { + desktopfiles | + xargs -I{} awk -F= '/^Name=/{ print $2;exit; }' {} | + sort -u + } + get_desktopfile() { + desktopfiles | + xargs -I{} awk -v name="$1" -F= '/^Name=/{ if($2==name) print FILENAME }' {} | + sort -u | + head -n1 + } + app=$(list_apps | MENU_PROMPT="" "$0") + [ -z "$app" ] && exit 0 + desktopfile=$(get_desktopfile "$app") + [ -z "$desktopfile" ] && exit 0 + nohup xdg-exec "$desktopfile" "$@" >/dev/null 2>&1 & + exit 0 ;; -p) shift @@ -36,17 +62,6 @@ while test $# -gt $idx; do idx=$((idx + 1)) done -# HACK: https://github.com/Cloudef/bemenu/issues/5 -args= [ -n "${MENU_PASSWORD}" ] && args="${args} --password" - -# make sure there we are the only running menu -pgrep "${arg0}" && pkill "${arg0}" - -exec "${arg0}" \ - --tb "$main_color" --tf '#fffffb' \ - --hb "$main_color" --hf '#fffffb' \ - --scb '#1c1c1c' --scf "$main_color" \ - --prompt="${prompt}" \ - ${args} \ - "$@" +[ -n "${MENU_POPUP}" ] && args="${args} --center --width-factor 0.5 --border 2 --list 8" # --fixed-height +exec "${arg0}" --prompt "${prompt}" ${args} "$@" |