#!/bin/sh
# wrapper around bemenu
# bmenu *       - use as dmenu, -p for custom prompt (man bemenu)
# bmenu run     - select from .desktop files and run it
# bmenu start   - internal option
if test "$1" != "start" || test "$1" = "run"
then
    test -n "$SWAYSOCK" && swaymsg fullscreen off > /dev/null
fi

if test "$1" = "run"
then
    test -n "$2" && t="$2" || t="terminal"
    exec j4-dmenu-desktop --dmenu="bmenu start -p Iniciar:" --term "$t"
fi

# t  title
# f  filter
# n  normal
# h  highlighted
# s  selected
# sc scrollbar

 fn="{{@@ font.mono @@}} 12"

 tb="{{@@ color.bg       @@}}"
 tf="{{@@ accent_color @@}}"

 fb="{{@@ color.bg       @@}}"
 ff="{{@@ color.txt    @@}}"

 nb="{{@@ color.bg       @@}}"
 nf="{{@@ color.txt    @@}}"

 hb="{{@@ color.bg_light @@}}"
 hf="{{@@ accent_color @@}}"

#{%@@ if False @@%}#
# Hacks to allow runnning even if not templated
 fn="Fira Code 12"

 tf="#D9534F"
 tb="#202020"

 ff="#ffffff"
 fb="#202020"

 nf="#ffffff"
 nb="#202020"

 hf="#D9534F"
 hb="#404040"
#{%@@ endif @@%}#

bemenu \
    --ignorecase\
    --bottom\
    --no-overlap\
    --list 20\
    --prefix '->'\
    --fn "$fn"\
    --tb "$tb" --tf "$tf" \
    --fb "$fb" --ff "$ff" \
    --nb "$nb" --nf "$nf" \
    --hb "$hb" --hf "$hf" \
    $@
