add fzf support, etc

This commit is contained in:
Jes Olson 2022-10-04 14:12:04 -05:00
parent 0c67bb1637
commit 9376d8cdc3
2 changed files with 23 additions and 1 deletions

11
README
View file

@ -10,3 +10,14 @@ examples:
# launch shmoji with bemenu # launch shmoji with bemenu
shmoji bemenu shmoji bemenu
# launch shmoji with fzf
shmoji fzf
how do i use this in...
sway/i3:
bindsym $mod+Shift+o exec --no-startup-id shmoji bemenu
shell:
shmoji fzf

13
shmoji
View file

@ -9,7 +9,7 @@
set -e set -e
cmd="$1" cmd="$1"
emojidb="$HOME/.local/share/emoji-bemenu" emojidb="$HOME/.local/share/shmoji"
emojifile="$emojidb/emojis.txt" emojifile="$emojidb/emojis.txt"
die() { die() {
@ -17,6 +17,10 @@ die() {
exit 1 exit 1
} }
emojicheck() {
[ -f "$emojifile" ] || die "emojis not found. try 'shmoji download'"
}
case "$cmd" in case "$cmd" in
download) download)
command -v curl > /dev/null || die 'curl not found' command -v curl > /dev/null || die 'curl not found'
@ -26,11 +30,18 @@ case "$cmd" in
curl 'https://trash.j3s.sh/emojis.txt' >"$emojidb/emojis.txt" curl 'https://trash.j3s.sh/emojis.txt' >"$emojidb/emojis.txt"
;; ;;
bemenu) bemenu)
emojicheck
command -v bemenu > /dev/null || die 'bemenu not found' command -v bemenu > /dev/null || die 'bemenu not found'
command -v wtype > /dev/null || die 'wtype not found' command -v wtype > /dev/null || die 'wtype not found'
emoji=$(cat "$emojidb/emojis.txt" | bemenu -c -W 0.2 -l 20) 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" "$emoji" | cut -d " " -f 1 | tr -d '\n' | wtype -
;; ;;
fzf)
emojicheck
command -v fzf > /dev/null || die 'fzf not found'
emoji=$(cat "$emojidb/emojis.txt" | fzf)
printf "%s" "$emoji" | cut -d " " -f 1 | tr -d '\n'
;;
*) *)
printf "%s\n" "usage: shmoji [bemenu | download]" printf "%s\n" "usage: shmoji [bemenu | download]"
;; ;;