diff --git a/scripts/copy-crosscode-emoji-url.sh b/scripts/copy-crosscode-emoji-url.sh new file mode 100755 index 0000000..c4834a0 --- /dev/null +++ b/scripts/copy-crosscode-emoji-url.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# shellcheck source=/dev/null +source ~/.config/copy-crosscode-emoji-url.conf.sh + +data_refs=() +data_urls=() +data_titles=() + +read_line() { + IFS= read -r "$@" +} + +# https://stackoverflow.com/a/15692004/12005228 +print_lines() { + eval "printf '%s\n' \"\${$1[@]}\"" +} + +while read_line ref && read_line url && read_line title; do + data_refs+=("$ref") + data_urls+=("$url") + data_titles+=("$title") +done < <( + curl --location --fail --max-time 10 "$CCBOT_EMOTE_REGISTRY_DUMP_URL" | + jq -r '.list[] | select(.safe) | .ref, .url, "\(.ref) [\(.guild_name)]"' +) + +if index="$(print_lines data_titles | rofi -dmenu -i -p cc-emoji -format i)"; then + echo -n "${data_urls[$index]}" | xsel --clipboard --input + notify-send --icon=utilities-terminal --expire-time=3000 "$0" "copied URL of ${data_refs[$index]} to clipboard!" +fi diff --git a/scripts/copy-text-face.sh b/scripts/copy-text-face.sh index 1d20dd5..40e368a 100755 --- a/scripts/copy-text-face.sh +++ b/scripts/copy-text-face.sh @@ -6,7 +6,7 @@ declare -A faces=( ["table flip"]=$'(\xe3\x83\x8e\xe0\xb2\xa0\xe7\x9b\x8a\xe0\xb2\xa0)\xe3\x83\x8e\xe5\xbd\xa1\xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb' ) -if IFS=$'\n' face_name="$(echo -e "${!faces[*]}" | rofi -dmenu)"; then +if IFS=$'\n' face_name="$(echo -E "${!faces[*]}" | rofi -dmenu -i)"; then face="${faces[$face_name]}" echo -n "$face" | xsel --clipboard --input notify-send --icon=utilities-terminal --expire-time=2500 "$0" "$face_name copied to clipboard"