From 32fc9f45ddafd06d0be47086c27aae6a351e5363 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 11 Apr 2023 21:59:24 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=A6=8A=20Update=20emoji=20url=20to=20?= =?UTF-8?q?latest=20version=20(#18)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Point url to grab emoji from to latest version of emoji list, which should automatically point to upcoming versions as well. Fixes #18. --- CHANGELOG.md | 4 +++- bemoji | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a86d5a..022b526 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - +### Fixed + +- Always download from newest emoji list url diff --git a/bemoji b/bemoji index d3df589..6da4e86 100755 --- a/bemoji +++ b/bemoji @@ -98,7 +98,7 @@ prepare_db() { dl_default_emoji() { local emojis - emojis=$(curl -sSL "https://unicode.org/Public/emoji/14.0/emoji-test.txt") + emojis=$(curl -sSL "https://unicode.org/Public/emoji/latest/emoji-test.txt") printf "%s" "$emojis" | sed -ne 's/^.*; fully-qualified.*# \(\S*\) \S* \(.*$\)/\1 \2/gp' >"$bm_db_location/emojis.txt" printf "Downloaded default emoji set.\n" } From 71d5dc455de7f7e0adb206d0fea2988daf39486e Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 11 Apr 2023 22:05:16 +0200 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=A6=8A=20Exit=20status=201=20on=20can?= =?UTF-8?q?celled=20selection=20(#20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When making no selection, i.e. cancelling during the selection process the program will return status code 1, whereas before it would carry the same return code as when making an emoji selection. Fixes #20. --- CHANGELOG.md | 4 +++- bemoji | 2 +- test/bemoji_cmds.bats | 5 +++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 022b526..e8b0972 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - +### Added + +- Pass through return code 1 from selection tool ### Changed diff --git a/bemoji b/bemoji index 6da4e86..1a7c35a 100755 --- a/bemoji +++ b/bemoji @@ -206,7 +206,7 @@ result=$(echo "$result" | grep -o '^\S\+' | tr -d '\n') case "$exit_value" in 1) - exit + exit 1 ;; 0) if [ ${#bm_cmds[@]} -eq 0 ]; then diff --git a/test/bemoji_cmds.bats b/test/bemoji_cmds.bats index 2d0f324..2b0a176 100644 --- a/test/bemoji_cmds.bats +++ b/test/bemoji_cmds.bats @@ -64,6 +64,11 @@ typing result" assert_output "my clipping" } +@test "Returns status code 1 on picker status code 1" { + BEMOJI_PICKER_CMD="return 1" run bemoji -e 3>&- + assert_failure 1 +} + @test "Prints output with newline by default" { bats_require_minimum_version 1.5.0 BEMOJI_PICKER_CMD="echo heart" run --keep-empty-lines -- bemoji -e From 302bc0ebf4d31e3a2cc8cf080242dd126dba29c8 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 11 Apr 2023 22:55:23 +0200 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=90=9B=20Pass=20through=20stdin=20to?= =?UTF-8?q?=20custom=20typing=20tool=20(#19)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, stdin contents were consumed and then not passed through to the typing tool. With this commit, they are correctly passed to any custom tool's stdin. Fixes #19. --- CHANGELOG.md | 1 + README.md | 2 ++ bemoji | 7 +++++-- test/bemoji_cmds.bats | 5 +++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8b0972..2786a06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Always download from newest emoji list url +- Pass selection to custom typing tools through stdin diff --git a/README.md b/README.md index f87eb72..4986da3 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,8 @@ BEMOJI_CLIP_CMD="path/to/your/clipboard/tool" BEMOJI_TYPE_CMD="path/to/your/xdotool" ``` +The candidate list (in the case of picker tool) or the picked selection are passed to the tools through stdin. + This is pretty experimental and you'll have to see how well it works for you. The setting can not be changed through the commandline alone. diff --git a/bemoji b/bemoji index 1a7c35a..10ce980 100755 --- a/bemoji +++ b/bemoji @@ -165,11 +165,14 @@ _clipper() { # Set default typing uti _typer() { - totype=$(cat -) if [ -n "$BEMOJI_TYPE_CMD" ]; then # shellcheck disable=SC2068 ${BEMOJI_TYPE_CMD[@]} - elif [ -n "$WAYLAND_DISPLAY" ] && command -v wtype >/dev/null 2>&1; then + return + fi + + totype=$(cat -) + if [ -n "$WAYLAND_DISPLAY" ] && command -v wtype >/dev/null 2>&1; then wtype -s 30 "$totype" elif [ -n "$DISPLAY" ] && command -v xdotool >/dev/null 2>&1; then xdotool type --delay 30 "$totype" diff --git a/test/bemoji_cmds.bats b/test/bemoji_cmds.bats index 2b0a176..ced326c 100644 --- a/test/bemoji_cmds.bats +++ b/test/bemoji_cmds.bats @@ -54,6 +54,11 @@ setup() { typing result" } +@test "Passes selection to custom typer tool through stdin" { + BEMOJI_TYPE_CMD="cat -" run bemoji -t 3>&- + assert_output "❤️" +} + @test "Runs custom default command" { BEMOJI_DEFAULT_CMD="echo my custom command" run bemoji 3>&- assert_output "my custom command"