diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-01-24 20:35:27 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-01-24 20:35:27 +0900 |
| commit | c80a54e42b52ce297f0f2f71af23c562832025c7 (patch) | |
| tree | dcce8bb977a770f473325d48f6f70b21d9818a40 /ar/.local/bin/emojiupdate | |
init
Diffstat (limited to 'ar/.local/bin/emojiupdate')
| -rwxr-xr-x | ar/.local/bin/emojiupdate | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/ar/.local/bin/emojiupdate b/ar/.local/bin/emojiupdate new file mode 100755 index 0000000..cc2f1c5 --- /dev/null +++ b/ar/.local/bin/emojiupdate @@ -0,0 +1,65 @@ +#!/bin/sh + +# Define input and output files +URL="https://unicode.org/Public/emoji/latest/emoji-test.txt" +INPUT_FILE="${XDG_DATA_HOME:-${HOME}/.local/share}/thesiah/char/emoji_raw" +TEMP_FILE="${XDG_DATA_HOME:-${HOME}/.local/share}/thesiah/char/emoji_temp" +OUTPUT_FILE="${XDG_DATA_HOME:-${HOME}/.local/share}/thesiah/char/emoji" + +# Create the directory for output files if it doesn't exist +mkdir -p "$(dirname "$INPUT_FILE")" + +# Download the emoji file +echo "Downloading emoji-test.txt from Unicode..." +if curl -o "$INPUT_FILE" -L "$URL"; then + echo "Download complete! File saved to: $INPUT_FILE" +else + echo "Failed to download emoji" + exit 1 +fi + +awk ' + # Skip empty lines and comments + /^[[:space:]]*$/ || /^#/ { next } + + # Keep only fully-qualified lines + !/(fully-qualified|component)/ { next } + + # Skip lines containing 200D (zero-width joiner) + /200D/ { next } + + # Skip lines containing components + $2 ~ /1F3F[BCDEF]/ { next } + + # Print valid lines + { print } +' "$INPUT_FILE" >"$TEMP_FILE" + +# Second stage: Extract emoji and description +awk -F'#' ' + { + if (NF >= 2) { + full_data = $2 # Extract the emoji and description (after #) + gsub(/^[[:space:]]+|[[:space:]]+$/, "", full_data) # Trim spaces around the entire field + + split(full_data, parts, " ") # Split into parts by spaces + emoji = parts[1] # First part is the emoji + + # Reconstruct description from parts[3] onward + description = "" + for (i = 3; i <= length(parts); i++) { + description = description parts[i] " " + } + + # Remove excessive internal spaces and trim description + gsub(/[[:space:]]+/, " ", description) + gsub(/^[[:space:]]+|[[:space:]]+$/, "", description) + + # Print emoji and description + print emoji, description + } + } +' "$TEMP_FILE" >"$OUTPUT_FILE" + +rm -rf "$INPUT_FILE" "$TEMP_FILE" +echo "Processing complete! File saved to: $OUTPUT_FILE" |
