#!/bin/sh # title="🇺 Unicode input" PATH=/home/zachariahdecook/.local/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:~/.local/bin:~/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin makefile() { mkdir -p ~/.cache/sxmo/ cat /usr/share/unicode/UnicodeData.txt | grep -v '' | grep -v '0020;SPACE' | busybox awk -F';' ' function hex2dec(h,i,x,v){ h=tolower(h);sub(/^0x/,"",h) for(i=1;i<=length(h);++i){ x=index("0123456789abcdef",substr(h,i,1)) if(!x)return"NaN" v=(16*v)+x-1 } return v } (1){ n = hex2dec($1); # UTF-8 Implementation (because "%lc" no worky in POSIX awk) if (n < 128) { printf("%c", n); } else if (n < 2048) { printf("%c%c", 192 + (n/64), 128 + n%64); } else if (n <= 0xFFFF) { printf("%c%c%c", 224 + (n/4096)%16,128 + (n/64)%64, 128 + n%64); } else { printf("%c%c%c%c", 240 + (n/262144), 128 + (n/4096)%64, 128 + (n/64)%64, 128 + n%64) } printf(" %s %s\n", $2, $11); }' > ~/.cache/sxmo/PrintableUnicodes.tsv } test -e ~/.cache/sxmo/PrintableUnicodes.tsv || makefile if test "$XDG_SESSION_TYPE" = x11; then printf "%s" $(cat ~/.cache/sxmo/PrintableUnicodes.tsv | sxmo_dmenu.sh -i | cut -d' ' -f1 | tee /dev/stderr) | xclip -selection clipboard else # can't wl-ime-type or wtype in pop-os wayland cat ~/.cache/sxmo/PrintableUnicodes.tsv | sxmo_dmenu.sh -i | cut -d' ' -f1 | tee /dev/stderr | xargs wl-copy #xargs -I{} wl-ime-type '{}' fi