shmoji/shmoji
2022-10-04 14:04:55 -05:00

39 lines
926 B
Bash
Executable file

#!/bin/sh
#
# shell-based emoji picker
#
# deps:
# - bemenu + wtype
# - curl, if you wanna download my emoji list
set -e
cmd="$1"
emojidb="$HOME/.local/share/emoji-bemenu"
emojifile="$emojidb/emojis.txt"
die() {
printf "%s\n" "$1"
exit 1
}
case "$cmd" in
download)
command -v curl > /dev/null || die 'curl not found'
mkdir -p "$emojidb"
# $ wc -l /var/www/trash.j3s.sh/emojis.txt
# 3570 /var/www/trash.j3s.sh/emojis.txt
curl 'https://trash.j3s.sh/emojis.txt' >"$emojidb/emojis.txt"
;;
bemenu)
command -v bemenu > /dev/null || die 'bemenu not found'
command -v wtype > /dev/null || die 'wtype not found'
emoji=$(cat "$emojidb/emojis.txt" | bemenu -c -W 0.2 -l 20)
printf "%s" "$emoji" | cut -d " " -f 1 | tr -d '\n' | wtype -
;;
*)
printf "%s\n" "usage: shmoji [bemenu | download]"
;;
esac
exit 0