#!/bin/bash

# Script to fast save unicode characters in your clipboard
# Input: Unicode Hexadecimal representation as $1
# Output: The unicode character saved in the clipboard

usage() {
	echo -e "Usage:\n  $0 {UNICODE}\n\n{UNICODE} must be 4 || 8 digit Hexadecimal."
    exit 1
}

if [[ $# -eq 0 ]] ; then
    usage
elif [[ $1 =~ [a-f0-9]{4} ]]; then
	setxkbmap es
	printf "\u$1" | xclip -selection clipboard
	notify-send "Unicode Copied to clipboard" "Unicode: $1 "
elif [[ $1 =~ [a-f0-9]{8} ]]; then
	setxkbmap es
	printf "\U$1" | xclip -selection clipboard
	notify-send "Unicode Copied to clipboard" "Unicode: $1 "
else
	usage
fi
