dotfiles/scripts/menu/menu
2023-10-12 09:07:50 -06:00

79 lines
1.5 KiB
Bash
Executable file

#!/bin/sh
# Script for using either bemenu or dmenu
# with preconfigured options
PROMPT="$1" ; MODE="$2"
# Configuration
MENU="dmenu"
col_nb="#121212" # Normal background
col_nf="#665c54" # Normal foreground
col_sb="#d3869b" # Selected background
col_sf="#121212" # Selected foreground
font="JetbrainsMono"
font_size="10"
# Print help
if [ "$PROMPT" = "" -o "$PROMPT" = "-h" ] ; then
printf "Usage: menu [prompt] [run/pass/empty]"
return 0
fi
# Check for 'pass' arg
[ "$MODE" = "pass" ] &&
BPASS="-x" && DPASS="-P"
# bemenu opts
BEMENU_OPTS=" \
-c \
-i \
-l 10 \
-M 5 \
-W 0.3 \
-B 2 \
--cw 2 \
--tb $col_sb \
--tf $col_sf \
--fb $col_nb \
--ff $col_nf \
--cb $col_nb \
--cf $col_nf \
--nb $col_nb \
--nf $col_nf \
--hb $col_sb \
--hf $col_sf \
--ab $col_nb \
--af $col_nf \
--bdr $col_sb \
--fn "$font" \
-p "$PROMPT" \
$BPASS \
"
# dmenu opts
DMENU_OPTS=" \
-c \
-i \
-l 10 \
-nb $col_nb \
-nf $col_nf \
-sb $col_sb \
-sf $col_sf \
-fn "$font:size=$font_size" \
-p "$PROMPT" \
$DPASS \
"
# If chosen bemenu, use this args
[ "$MENU" = "bemenu" ] &&
OPTS="$BEMENU_OPTS" &&
RUN="-run"
# If chosen dmenu, use this args
[ "$MENU" = "dmenu" ] &&
OPTS="$DMENU_OPTS" &&
RUN="_run"
[ "$MODE" = "run" ] && $MENU$RUN $OPTS
[ "$MODE" = "pass" ] && < /dev/null | $MENU $OPTS
[ "$MODE" = "empty" ] && < /dev/null | $MENU $OPTS
[ -z "$MODE" ] && $MENU $OPTS