From 2d414258ca6b45bd3090b0f0bbcb41f724309417 Mon Sep 17 00:00:00 2001 From: Joe Groocock Date: Wed, 22 Jul 2020 20:54:58 +0100 Subject: [PATCH] rofi-emoji: replace rofi-emoji script with rofi plugin https://github.com/Mange/rofi-emoji Signed-off-by: Joe Groocock --- .config/i3/config | 2 +- scripts/rofi-emoji | 112 --------------------------------------------- 2 files changed, 1 insertion(+), 113 deletions(-) delete mode 100644 scripts/rofi-emoji diff --git a/.config/i3/config b/.config/i3/config index 0f8d97f..d1c8ea1 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -142,7 +142,7 @@ bindsym $mod+Ctrl+v exec systemd-run-i3 -n alacritty --class floatin bindsym $mod+l exec dm-tool switch-to-greeter bindsym $mod+space exec "pkill rofi; rofi -show run -sidebar-mode -terminal i3-sensible-terminal -normal-window -run-command 'systemd-run-i3 -n {cmd}'" bindsym $mod+Shift+p exec rofi-pass --root $(grep path ~/.config/gopass/config.yml | sed -E 's|^.*fs\+file://||g' | tr '\n' ':') | sed 's/:$//g' -bindsym $mod+Shift+e exec rofi-emoji +bindsym $mod+Shift+e exec "pkill rofi; rofi -show emoji -modi emoji -normal-window" bindsym $mod+Shift+i exec rofi-fontawesome bindsym --release Print exec screenshot bindsym --release $mod+Print exec imgur-screenshot diff --git a/scripts/rofi-emoji b/scripts/rofi-emoji deleted file mode 100644 index a0fae33..0000000 --- a/scripts/rofi-emoji +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/env bash -# -# Use rofi to pick emoji because that's what this -# century is about apparently... -# -# Requirements: -# rofi, xclip, xdotool, curl, xmllint -# -# Usage: -# 1. Download all emoji -# $ rofi-emoji --download -# -# 2. Run it! -# $ rofi-emoji -# -# Notes: -# * You'll need a emoji font like "Noto Emoji" or "EmojiOne". -# * Confirming an item will automatically paste it WITHOUT -# writing it to your clipboard. -# * Ctrl+C will copy it to your clipboard WITHOUT pasting it. -# - -# Where to save the emojis file. -EMOJI_FILE="${XDG_CACHE_DIR:-$HOME/.cache}/emojis.txt" - -# Urls of emoji to download. -URLS=( - 'https://emojipedia.org/people/' - 'https://emojipedia.org/nature/' - 'https://emojipedia.org/food-drink/' - 'https://emojipedia.org/activity/' - 'https://emojipedia.org/travel-places/' - 'https://emojipedia.org/objects/' - 'https://emojipedia.org/symbols/' - 'https://emojipedia.org/flags/' - 'https://emojipedia.org/modifiers/' -) - - -function download() { - notify "$(basename "$0")" 'Downloading all emoji for your pleasure' - - echo -n > "$EMOJI_FILE" - - for url in "${URLS[@]}"; do - echo "Downloading: $url" - - # Download the list of emoji and remove all the junk around it - emojis=$(curl -s "$url" | \ - xmllint --html \ - --xpath '//ul[@class="emoji-list"]' - 2>/dev/null) - - # Get rid of starting/closing ul tags - emojis=$(echo "$emojis" | head -n -1 | tail -n +1) - - # Extract the emoji and its description - emojis=$(echo "$emojis" | \ - sed -rn 's/.*(.*)<\/span> (.*)<\/a><\/li>/\1 \2/p') - - echo "$emojis" >> "$EMOJI_FILE" - done - - notify "$(basename "$0")" "We're all set!" -} - -function repeat() { - local rplc str="$1" count="$2" - rplc="$(printf "%${count}s")" - echo "${rplc// /"$str"}" -} - -function notify() { - if which notify-send 1>/dev/null 2>/dev/null; then - notify-send "$1" "$2" - fi -} - -function display() { - emoji=$(cat "$EMOJI_FILE" | grep -v '#' | grep -v '^[[:space:]]*$') - update="⏫ Update emoji cache" - emoji=$(printf "$emoji\n$update") - line=$(echo "$emoji" | rofi -dmenu -i -p emoji -normal-window -kb-custom-1 Ctrl+c -kb-row-tab '' -kb-row-select Tab $@) - - if [ "${line[@]}" == "$update" ]; then - download - display - return - fi - - line=($line) - last=${line[${#line[@]}-1]} - - quantifier="${last:${#last}-1:1}" - echo "$quantifier" | egrep -q '^[0-9]+$' || quantifier=1 - emojis="$(repeat "${line[0]}" "$quantifier")" - - sleep 0.1 - # Type the emojis, and put them in the clipboard - xdotool type --clearmodifiers "$emojis" - printf "%s" "$emojis" | xclip -i -selection CLIPBOARD -} - - -if [[ "$1" =~ -D|--download ]]; then - download - exit 0 -elif [[ "$1" =~ -h|--help ]]; then - echo "usage: $0 [-D|--download]" - exit 0 -fi - -display