From 9376d8cdc347b194e0b8ce15fed2ea669626290c Mon Sep 17 00:00:00 2001 From: Jes Olson Date: Tue, 4 Oct 2022 14:12:04 -0500 Subject: [PATCH] add fzf support, etc --- README | 11 +++++++++++ shmoji | 13 ++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README b/README index 545b28c..054598f 100644 --- a/README +++ b/README @@ -10,3 +10,14 @@ examples: # launch shmoji with 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 diff --git a/shmoji b/shmoji index f6465d0..18bd6da 100755 --- a/shmoji +++ b/shmoji @@ -9,7 +9,7 @@ set -e cmd="$1" -emojidb="$HOME/.local/share/emoji-bemenu" +emojidb="$HOME/.local/share/shmoji" emojifile="$emojidb/emojis.txt" die() { @@ -17,6 +17,10 @@ die() { exit 1 } +emojicheck() { + [ -f "$emojifile" ] || die "emojis not found. try 'shmoji download'" +} + case "$cmd" in download) 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" ;; bemenu) + emojicheck 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 - ;; + 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]" ;;