#!/bin/fish
# 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 "$argv[1]" != "start" || test "$argv[1]" = "run"
    test -n "$SWAYSOCK" && swaymsg fullscreen off > /dev/null
end

if test "$argv[1]" = "run"
    test -n "$2" && set t "$2" || set t "terminal"
    exec j4-dmenu-desktop --dmenu="bmenu start -p Iniciar:" --term "$t"
end

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

set -l fn "{{@@ font.mono @@}} 12"

set -l tb "{{@@ color.bg       @@}}"
set -l tf "{{@@ color.accent @@}}"

set -l fb "{{@@ color.bg       @@}}"
set -l ff "{{@@ color.txt    @@}}"

set -l nb "{{@@ color.bg       @@}}"
set -l nf "{{@@ color.txt    @@}}"

set -l hb "{{@@ color.bg_light @@}}"
set -l hf "{{@@ color.accent @@}}"

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

set -l tf "#D9534F"
set -l tb "#202020"

set -l ff "#ffffff"
set -l fb "#202020"

set -l nf "#ffffff"
set -l nb "#202020"

set -l hf "#D9534F"
set -l 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" \
    $argv
