From 3085bc77b3f1fcc31259997a30be306a4d80f6bc Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Tue, 23 Feb 2021 13:29:45 +0100 Subject: bin/menu: pass bemenu options globally through env var --- .profile | 2 ++ bin/menu | 42 ++++++++++++++++-------------------------- bin/mnts | 4 ++-- bin/soundswitch | 36 +++++++++++++++++++++++------------- 4 files changed, 43 insertions(+), 41 deletions(-) diff --git a/.profile b/.profile index b2c5411..2696b07 100644 --- a/.profile +++ b/.profile @@ -59,3 +59,5 @@ export LESS='--hilite-search --hilite-unread --long-prompt --raw-control-chars - # Set the rsync ssh command to use by default export RSYNC_RSH='ssh -T -x -o Compression=no' + +export BEMENU_OPTS='--ignorecase --no-overlap --fn "Iosevka SS14 Extended 11" --nb "#1c1c1c" --nf "#fffffb" --tb "#4E4371" --tf "#fffffb" --fb "#1c1c1c" --ff "#fffffb" --sb "#ddd23b" --sf "#1c1c1c" --hb "#4E4371" --hf "#fffffb" --scb "#1c1c1c" --scf "#4E4371"' diff --git a/bin/menu b/bin/menu index 82979d5..954755d 100755 --- a/bin/menu +++ b/bin/menu @@ -3,22 +3,24 @@ set -e [ -n "$DEBUG" ] && set -x arg0=bemenu -prompt=${MENU_PROMPT:-">"} +# prompt=${MENU_PROMPT:-󰈶 :} +prompt=${MENU_PROMPT:-󰈶󰩤} main_color="#4E4371" +args= idx=0 while test $# -gt $idx; do case "$1" in -run) - arg0=bemenu-run; prompt=bin - prompt="run" + arg0=bemenu-run + prompt=" 󰏌 " shift ;; -drun) # arg0=$HOME/devel/upstream/github.com/Cloudef/bemenu/bemenu-drun; prompt=bin - arg0=bemenu-drun; prompt=bin - prompt="drun" - main_color="#DB4D60" + arg0=bemenu-drun + prompt=" 󱂬 " + main_color="#e03c8a" shift ;; -p) @@ -26,36 +28,24 @@ while test $# -gt $idx; do prompt="$1" shift ;; + -x) + shift; MENU_PASSWORD=1 ;; esac idx=$((idx+1)) done # HACK: https://github.com/Cloudef/bemenu/issues/5 -# fb='#221E1D' -# ff='#fffefe' -# [ -n "${MENU_PASSWORD}" ] && ff=$fb -# TODO submit https://github.com/robertgzr/bemenu/tree/passwd -passwd_arg= -[ -n "${MENU_PASSWORD}" ] && passwd_arg=--password +args= +[ -n "${MENU_PASSWORD}" ] && args="${args} --password" # make sure there we are the only running menu pgrep "${arg0}" && pkill "${arg0}" - # --monitor=1 \ exec "${arg0}" \ - --no-overlap \ - --ignorecase \ - --list=10 \ + --tb "$main_color" --tf '#fffffb' \ + --hb "$main_color" --hf '#fffffb' \ + --scb '#1c1c1c' --scf "$main_color" \ --prompt="${prompt}" \ - --fn 'Iosevka SS14 Extended 11' \ - --nb '#221E1D' --nf '#fffefe' \ - --tb "$main_color" --tf '#fffefe' \ - --fb '#221E1D' --ff '#fffefe' \ - --sb '#FAD689' \ - --sf '#221E1D' \ - --hb "$main_color" \ - --hf '#FCFAF2' \ - --scb '#221E1D' --scf '#fffefe' \ - ${passwd_arg} \ + ${args} \ "$@" diff --git a/bin/mnts b/bin/mnts index cb1093c..817d372 100755 --- a/bin/mnts +++ b/bin/mnts @@ -14,7 +14,7 @@ for app in awk jq lsblk notify-send udisksctl; do fi done -export MENU_PROMPT="mnts" +export MENU_PROMPT="󰕓 mnts" handle() { line=$(awk '{print $0}') @@ -36,5 +36,5 @@ handle() { lsblk -fJ \ | jq -r '.. | select(.uuid?!="" and .name?) | select((.name | test("hibiki|nvme") | not) and .fstype?) | [ .name, .label, .mountpoint // "" ] | @tsv' \ | awk -F'\t' '{printf "/dev/%-10s\t%-15s\t%s\n", $1, $2, $3;}' \ - | menu \ + | menu --list=8 \ | handle diff --git a/bin/soundswitch b/bin/soundswitch index 3f893c6..acd287a 100755 --- a/bin/soundswitch +++ b/bin/soundswitch @@ -15,12 +15,14 @@ for tool in jq swq pactl perl; do fi done - - DEFAULT_PROFILE="output:analog-stereo+input:analog-stereo" HDMI_PROFILE="output:hdmi-stereo" export MENU_PROMPT="soundswitch" +_menu() { + menu -l 8 +} + mode= output= input= @@ -67,29 +69,37 @@ done shift $((OPTIND-1)) # ask mode +_mode_global="󰣨 global" +_mode_focused="󰻿 focused" +_mode_profile_card="󱂇 card profile" +_mode_profile_hdmi="󰡁 hdmi profile" +_mode_profile_reset="󰕍 reset profile" if [ -z "$mode" ]; then - printf "global\nfocused\ncard profile\nhdmi profile\nreset profile\n" | menu | { + printf "$_mode_global\n$_mode_focused\n$_mode_profile_card\n$_mode_profile_hdmi\n$_mode_profile_reset\n" | _menu | { read -r line case ${line} in - global) exec "$0" -g "$*" ;; - focused) exec "$0" -f "$*" ;; - "card profile") exec "$0" -p "$*" ;; - "hdmi profile") exec "$0" -H "$*" ;; - "reset profile") exec "$0" -R "$*" ;; - *) usage ;; + $_mode_global) exec "$0" -g "$*" ;; + $_mode_focused) exec "$0" -f "$*" ;; + $_mode_profile_card) exec "$0" -p "$*" ;; + $_mode_profile_hdmi) exec "$0" -H "$*" ;; + $_mode_profile_reset) exec "$0" -R "$*" ;; + *) + usage ;; esac } exit $? fi +_mode_output="󰴸 output" +_mode_input="󰍬 input" if [ -n "$mode" ]; then # ask target? if [ -z "$output" ] && [ -z "$input" ]; then - printf "output\ninput\n" | menu | { + printf "$_mode_output\n$_mode_input\n" | _menu | { read -r line case ${line} in - output) exec "$0" -O $_args ;; - input) exec "$0" -I $_args ;; + $_mode_output) exec "$0" -O $_args ;; + $_mode_input) exec "$0" -I $_args ;; *) usage ;; esac } @@ -177,7 +187,7 @@ profile) | cut -d'~' -f2- \ | tr '\r' '\n' \ | xargs -L1 \ - | menu \ + | _menu \ | perl -pe 's/^\s*([^\s]+):\s.*$/\1/') if [ -z "${target_profile}" ]; then exit 1 -- cgit 1.4.1