Added another fn to perform typing and sending to clipboard together.
Introduced a new argument `-b`. using this will send the emoji to clipboard after typing it. * could have been written in more efficient way. (but followed the previous code style to blend it.)
This commit is contained in:
parent
7cec73e2db
commit
7d230bfecd
1 changed files with 25 additions and 1 deletions
26
bemoji
26
bemoji
|
|
@ -28,6 +28,7 @@ usage() {
|
||||||
echo " -f <filepath> Use a custom emoji database. Can be a url which will be retrieved."
|
echo " -f <filepath> Use a custom emoji database. Can be a url which will be retrieved."
|
||||||
echo " -t Simulate typing the emoji choice with the keyboard."
|
echo " -t Simulate typing the emoji choice with the keyboard."
|
||||||
echo " -c Send emoji choice to the clipboard. (default)"
|
echo " -c Send emoji choice to the clipboard. (default)"
|
||||||
|
echo " -b Simulate typing and sending emoji to clipboard."
|
||||||
echo " -p Do not save picked emoji to recent history."
|
echo " -p Do not save picked emoji to recent history."
|
||||||
echo " -P Do not order emoji by recently used."
|
echo " -P Do not order emoji by recently used."
|
||||||
echo " -e Only echo out the picked emoji."
|
echo " -e Only echo out the picked emoji."
|
||||||
|
|
@ -45,11 +46,12 @@ version() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get Options
|
# Get Options
|
||||||
while getopts ":f:D:tcepPhv" o; do
|
while getopts ":f:D:tcbepPhv" o; do
|
||||||
case "${o}" in
|
case "${o}" in
|
||||||
f) BEMOJI_CUSTOM_LIST="${OPTARG}" ;;
|
f) BEMOJI_CUSTOM_LIST="${OPTARG}" ;;
|
||||||
t) bm_default_cmd=_typeResult ;;
|
t) bm_default_cmd=_typeResult ;;
|
||||||
c) bm_default_cmd=_clipResult ;;
|
c) bm_default_cmd=_clipResult ;;
|
||||||
|
b) bm_default_cmd=_typeClipResult ;;
|
||||||
e) bm_default_cmd=_echo ;;
|
e) bm_default_cmd=_echo ;;
|
||||||
D) BEMOJI_DOWNLOAD_LIST="${OPTARG}" ;;
|
D) BEMOJI_DOWNLOAD_LIST="${OPTARG}" ;;
|
||||||
p) bm_private_mode=true ;;
|
p) bm_private_mode=true ;;
|
||||||
|
|
@ -186,6 +188,24 @@ _picker() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Set default typing uti
|
||||||
|
_typeClipper() {
|
||||||
|
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
|
||||||
|
wtype -s 30 "$totype"
|
||||||
|
elif [ -n "$DISPLAY" ] && command -v xdotool >/dev/null 2>&1; then
|
||||||
|
xdotool type --delay 30 "$totype"
|
||||||
|
else
|
||||||
|
printf "No suitable typing tool found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo $1
|
||||||
|
echo "$totype" | _clipper
|
||||||
|
}
|
||||||
|
|
||||||
# Type result using xdotool
|
# Type result using xdotool
|
||||||
_typeResult() {
|
_typeResult() {
|
||||||
cat - | _typer
|
cat - | _typer
|
||||||
|
|
@ -195,6 +215,10 @@ _clipResult() {
|
||||||
cat - | _clipper
|
cat - | _clipper
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_typeClipResult() {
|
||||||
|
cat - | _typeClipper
|
||||||
|
}
|
||||||
|
|
||||||
[ -n "$BEMOJI_CUSTOM_LIST" ] || prepare_db
|
[ -n "$BEMOJI_CUSTOM_LIST" ] || prepare_db
|
||||||
result=$(gather_emojis | _picker)
|
result=$(gather_emojis | _picker)
|
||||||
exit_value="$?"
|
exit_value="$?"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue