✨Add support for ilia desktop executor
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
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:
parent
011fcdefdd
commit
74af60c3f7
3 changed files with 29 additions and 15 deletions
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- Add default support for `ilia` gtk-based picker tool, used by default in Regolith Linux
|
||||||
- Pass through return code 1 from selection tool
|
- Pass through return code 1 from selection tool
|
||||||
- (!) Number of displayed recent emoji can be set with `-P` option:
|
- (!) 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
|
This replaces previous `-P` history flag toggle. Use number to set amount of recent
|
||||||
|
|
|
@ -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.
|
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.
|
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
34
bemoji
|
@ -20,6 +20,14 @@ bm_private_mode=${BEMOJI_PRIVATE_MODE:-false}
|
||||||
# Do not sort results
|
# Do not sort results
|
||||||
bm_limit_recent="$BEMOJI_LIMIT_RECENT"
|
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
|
# Report usage
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: $(basename "$0") [-t | -c | -e] [-f <filepath> ] [-p] [-P] [-D <choices>]" 1>&2
|
echo "Usage: $(basename "$0") [-t | -c | -e] [-f <filepath> ] [-p] [-P] [-D <choices>]" 1>&2
|
||||||
|
@ -227,7 +235,7 @@ _clipper() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set default typing uti
|
# Set default typing util
|
||||||
_typer() {
|
_typer() {
|
||||||
if [ -n "$BEMOJI_TYPE_CMD" ]; then
|
if [ -n "$BEMOJI_TYPE_CMD" ]; then
|
||||||
# shellcheck disable=SC2068
|
# shellcheck disable=SC2068
|
||||||
|
@ -251,18 +259,18 @@ _picker() {
|
||||||
if [ -n "$BEMOJI_PICKER_CMD" ]; then
|
if [ -n "$BEMOJI_PICKER_CMD" ]; then
|
||||||
# shellcheck disable=SC2068
|
# shellcheck disable=SC2068
|
||||||
${BEMOJI_PICKER_CMD[@]}
|
${BEMOJI_PICKER_CMD[@]}
|
||||||
elif command -v bemenu >/dev/null 2>&1; then
|
return
|
||||||
bemenu -p 🔍 -i -l 20
|
fi
|
||||||
elif command -v wofi >/dev/null 2>&1; then
|
|
||||||
wofi -p 🔍 -i --show dmenu
|
for tool in "${!default_pickers[@]}"; do
|
||||||
elif command -v rofi >/dev/null 2>&1; then
|
if command -v "$tool" >/dev/null 2>&1; then
|
||||||
rofi -p 🔍 -i -dmenu --kb-custom-1 "Alt+1" --kb-custom-2 "Alt+2"
|
${default_pickers[$tool]}
|
||||||
elif command -v dmenu >/dev/null 2>&1; then
|
return
|
||||||
dmenu -p 🔍 -i -l 20
|
fi
|
||||||
else
|
done
|
||||||
printf "No suitable picker tool found."
|
|
||||||
exit 1
|
printf "No suitable picker tool found." 1>&2
|
||||||
fi
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_cli "$@"
|
parse_cli "$@"
|
||||||
|
|
Loading…
Reference in a new issue