diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ce174c..1b9b5da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Add default support for `ilia` gtk-based picker tool, used by default in Regolith Linux - Pass through return code 1 from selection tool - (!) Number of displayed recent emoji can be set with `-P` option: This replaces previous `-P` history flag toggle. Use number to set amount of recent diff --git a/README.md b/README.md index 0b7af3f..a946f9b 100644 --- a/README.md +++ b/README.md @@ -284,7 +284,12 @@ If you have an idea or improvement, don't hesitate to open a merge request! This project makes use of [bash-bats](https://github.com/bats-core/bats-core) (community fork) to test some of its functionality. -To run the tests locally, simply execute `./test/bats/bin/bats test`. +To run the tests locally: +``` +git submodule init +git submodule update +./test/bats/bin/bats test +``` I would suggest running the test suite in docker instead, just to minimize the possibility of something going awry and borking up your local file system. -To run the tests in a docker suite, execute `docker run --rm -it -v "$PWD:/code" bats/bats:latest /code/test` +To run the tests in a docker suite, execute `docker run --rm -it -v "$PWD:/code" bats/bats:latest /code/test` after initializing the git submodules as listed above. diff --git a/bemoji b/bemoji index 82464cb..a3fd400 100755 --- a/bemoji +++ b/bemoji @@ -20,6 +20,14 @@ bm_private_mode=${BEMOJI_PRIVATE_MODE:-false} # Do not sort results bm_limit_recent="$BEMOJI_LIMIT_RECENT" +declare -A default_pickers=( + ["bemenu"]="bemenu -p 🔍 -i -l 20" + ["wofi"]="wofi -p 🔍 -i --show dmenu" + ["rofi"]="rofi -p 🔍 -i -dmenu --kb-custom-1 "Alt+1" --kb-custom-2 "Alt+2"" + ["dmenu"]="dmenu -p 🔍 -i -l 20" + ["ilia"]="ilia -n -p textlist -l 'Emoji' -i desktop-magnifier" +) + # Report usage usage() { echo "Usage: $(basename "$0") [-t | -c | -e] [-f ] [-p] [-P] [-D ]" 1>&2 @@ -227,7 +235,7 @@ _clipper() { fi } -# Set default typing uti +# Set default typing util _typer() { if [ -n "$BEMOJI_TYPE_CMD" ]; then # shellcheck disable=SC2068 @@ -251,18 +259,18 @@ _picker() { if [ -n "$BEMOJI_PICKER_CMD" ]; then # shellcheck disable=SC2068 ${BEMOJI_PICKER_CMD[@]} - elif command -v bemenu >/dev/null 2>&1; then - bemenu -p 🔍 -i -l 20 - elif command -v wofi >/dev/null 2>&1; then - wofi -p 🔍 -i --show dmenu - elif command -v rofi >/dev/null 2>&1; then - rofi -p 🔍 -i -dmenu --kb-custom-1 "Alt+1" --kb-custom-2 "Alt+2" - elif command -v dmenu >/dev/null 2>&1; then - dmenu -p 🔍 -i -l 20 - else - printf "No suitable picker tool found." - exit 1 - fi + return + fi + + for tool in "${!default_pickers[@]}"; do + if command -v "$tool" >/dev/null 2>&1; then + ${default_pickers[$tool]} + return + fi + done + + printf "No suitable picker tool found." 1>&2 + exit 1 } parse_cli "$@"