Add support for ilia desktop executor
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

Ilia is used by Regolith Linux (Ubuntu+i3/sway).

Ilia has a slightly different presentation and prompt setup than other
pickers, and it makes more sense to use the given GTK icon instead of
the emoji character since that is what it seems to support.

Nicely explained by @jc00ke here:
https://github.com/marty-oehme/bemoji/pull/21#discussion_r1306212419

With the growing amount of picker tools supported out of the box
it seems more practical to have them together in a simple list
that can grow and through which we can always iterate instead
of a cumbersome growing if-else chain.
This commit also refactors the pick tool selection to be stored in
a bash hash map instead.
This commit is contained in:
Jesse Cooke 2023-09-14 17:14:39 +02:00 committed by Marty Oehme
parent 011fcdefdd
commit 74af60c3f7
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
3 changed files with 29 additions and 15 deletions

View file

@ -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

View file

@ -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.

34
bemoji
View file

@ -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 <filepath> ] [-p] [-P] [-D <choices>]" 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 "$@"