🐛 Pass through stdin to custom typing tool (#19)

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.
This commit is contained in:
Marty Oehme 2023-04-11 22:55:23 +02:00
parent 71d5dc455d
commit 56ae0f1bab
Signed by: Marty
GPG Key ID: EDBF2ED917B2EF6A
4 changed files with 13 additions and 2 deletions

View File

@ -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
<!-- ### Security -->

View File

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

7
bemoji
View File

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

View File

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