aboutsummaryrefslogblamecommitdiff
path: root/.local/bin/emoji-menu
blob: 6b205134c27ce39127fd95dd6ea469bec87dbf9a (plain) (tree)


















                                                                                                                  
#!/bin/sh -eu
# From: https://git.sr.ht/~emersion/dotfiles/tree/6575f89856d012c2c31e9e7d2c807f350c7503d4/item/bin/emoji-menu
# This version uses `fuzzel` instead of `menu`.

default_cache_home=~/.cache
cache_home="${XDG_CACHE_HOME:-$default_cache_home}"
mkdir -p "$cache_home"
data_file="$cache_home/emoji-menu.json"

if ! [ -f "$data_file" ]; then
	curl -o "$data_file" -L "https://github.com/github/gemoji/raw/master/db/emoji.json"
fi

filter='.[] | (.emoji + " " + .description + " (" + (.aliases | join(", ")) + ")")'
sel="$(jq -r "$filter" <"$data_file" | fuzzel --no-exit-on-keyboard-focus-loss -d | cut -d ' ' -f 1 | tr -d '\n')"
if [ -n "$sel" ]; then
	# wl-ime-type "$sel"
	wl-copy "$sel"
fi