2022-03-10 21:52:12 +01:00
|
|
|
|
{
|
|
|
|
|
|
lib,
|
|
|
|
|
|
runCommand,
|
|
|
|
|
|
fetchurl,
|
|
|
|
|
|
writeText,
|
|
|
|
|
|
writers,
|
|
|
|
|
|
coreutils,
|
|
|
|
|
|
dmenu,
|
|
|
|
|
|
gnused,
|
|
|
|
|
|
libnotify,
|
|
|
|
|
|
xclip,
|
|
|
|
|
|
xdotool,
|
|
|
|
|
|
gawk,
|
2023-10-06 10:50:31 +02:00
|
|
|
|
fetchFromGitHub,
|
2022-03-10 21:52:12 +01:00
|
|
|
|
}: let
|
2023-10-06 10:50:31 +02:00
|
|
|
|
emoji-flags = builtins.fromJSON (builtins.readFile "${fetchFromGitHub {
|
|
|
|
|
|
owner = "matiassingers";
|
|
|
|
|
|
repo = "emoji-flags";
|
|
|
|
|
|
rev = "93ae74505d09bb55a3eb3a511f1dfc0dd60a5347";
|
|
|
|
|
|
sha256 = "10j73sx6jb250v37bz2p7w8big0v8da3r6kpqz9xcl667gl8svwx";
|
|
|
|
|
|
}}/data.json");
|
|
|
|
|
|
emoji-flags-file = writeText "emoji-flags.txt" (lib.strings.concatMapStringsSep "\n" ({
|
|
|
|
|
|
emoji,
|
|
|
|
|
|
title,
|
|
|
|
|
|
...
|
|
|
|
|
|
}: "${emoji} ${title}")
|
|
|
|
|
|
emoji-flags);
|
2022-01-12 18:02:59 +01:00
|
|
|
|
unicode-file = runCommand "unicode.txt" {} ''
|
2022-03-10 21:52:12 +01:00
|
|
|
|
${
|
|
|
|
|
|
writers.writePython3 "generate.py" {flakeIgnore = ["E501" "E722"];} ''
|
|
|
|
|
|
import csv
|
2022-01-12 18:02:59 +01:00
|
|
|
|
|
2022-03-10 21:52:12 +01:00
|
|
|
|
with open("${
|
|
|
|
|
|
fetchurl {
|
|
|
|
|
|
url = "https://unicode.org/Public/UCD/latest/ucd/UnicodeData.txt";
|
2022-09-19 07:29:12 +02:00
|
|
|
|
sha256 = "0wva6ygnh3wrzpzy0kcbc32hz1ydx3k2pqc5xkqrfw83cpnrlvl0";
|
2022-03-10 21:52:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
}", "r") as unicode_data:
|
|
|
|
|
|
reader = csv.reader(unicode_data, delimiter=";")
|
|
|
|
|
|
next(reader) # skip first row containing \0
|
|
|
|
|
|
for row in reader:
|
|
|
|
|
|
codepoint = row[0]
|
|
|
|
|
|
name = row[1]
|
|
|
|
|
|
alternate_name = row[10]
|
|
|
|
|
|
try:
|
|
|
|
|
|
print(chr(int(codepoint, 16)), codepoint, name, alternate_name, sep=" ")
|
|
|
|
|
|
except:
|
|
|
|
|
|
continue
|
|
|
|
|
|
''
|
|
|
|
|
|
} > $out
|
2022-01-12 18:02:59 +01:00
|
|
|
|
'';
|
2021-03-04 18:54:48 +01:00
|
|
|
|
kaomoji-file = writeText "kaomoji.txt" ''
|
2022-01-12 18:02:59 +01:00
|
|
|
|
¯\(°_o)/¯ dunno lol shrug dlol
|
|
|
|
|
|
¯\_(ツ)_/¯ dunno lol shrug dlol
|
|
|
|
|
|
( ͡° ͜ʖ ͡°) lenny
|
|
|
|
|
|
¯\_( ͡° ͜ʖ ͡°)_/¯ lenny shrug dlol
|
|
|
|
|
|
( ゚д゚) aaah sad noo
|
|
|
|
|
|
ヽ(^o^)丿 hi yay hello
|
|
|
|
|
|
(^o^: ups hehe
|
|
|
|
|
|
(^∇^) yay
|
|
|
|
|
|
┗(`皿´)┛ angry argh
|
|
|
|
|
|
ヾ(^_^) byebye!! bye
|
|
|
|
|
|
<(^.^<) <(^.^)> (>^.^)> (7^.^)7 (>^.^<) dance
|
|
|
|
|
|
(-.-)Zzz... sleep
|
|
|
|
|
|
(∩╹□╹∩) oh noes woot
|
|
|
|
|
|
(╯°□°)╯ ┻━┻ table flip
|
|
|
|
|
|
(」゜ロ゜)」 why woot
|
|
|
|
|
|
(_゜_゜_) gloom I see you
|
|
|
|
|
|
༼ ༎ຶ ෴ ༎ຶ༽ sad
|
|
|
|
|
|
(\/) (°,,,,°) (\/) krebs
|
|
|
|
|
|
┳━┳ ヽ(ಠل͜ಠ)ノ putting table back
|
|
|
|
|
|
┻━┻︵ \(°□°)/ ︵ ┻━┻ flip all dem tablez
|
|
|
|
|
|
(`・ω・´) bear look
|
|
|
|
|
|
ᕦ(ຈل͜ຈ)ᕤ strong flex muscle bicep
|
|
|
|
|
|
ᕦ(ò_óˇ)ᕤ strong flex muscle bicep
|
|
|
|
|
|
(๑>ᴗ<๑) excite
|
|
|
|
|
|
(∩ ` -´)⊃━━☆゚.*・。゚ wizard spell magic
|
|
|
|
|
|
◕ ◡ ◕ puss in boots big eye
|
|
|
|
|
|
≋≋≋≋≋̯̫⌧̯̫(ˆ•̮ ̮•ˆ) nyan cat
|
|
|
|
|
|
ʕ•ᴥ•ʔ bear
|
|
|
|
|
|
(ԾɷԾ) adventure time
|
|
|
|
|
|
(⁀ᗢ⁀) happy yay
|
|
|
|
|
|
(≧◡≦) happy yay
|
|
|
|
|
|
\(º □ º )/ panic
|
|
|
|
|
|
𓂺 penis
|
|
|
|
|
|
𓂸 penis
|
2021-03-04 18:54:48 +01:00
|
|
|
|
'';
|
2022-03-10 21:52:12 +01:00
|
|
|
|
in
|
|
|
|
|
|
# ref https://github.com/LukeSmithxyz/voidrice/blob/9fe6802122f6e0392c7fe20eefd30437771d7f8e/.local/bin/dmenuunicode
|
|
|
|
|
|
writers.writeDashBin "unicodmenu" ''
|
2022-05-10 19:29:39 +02:00
|
|
|
|
history_file=$HOME/.cache/unicodmenu
|
2024-09-22 00:37:30 +02:00
|
|
|
|
touch "$history_file"
|
2022-08-21 01:03:24 +02:00
|
|
|
|
PATH=${lib.makeBinPath [coreutils dmenu gawk gnused libnotify xclip xdotool]}
|
|
|
|
|
|
|
|
|
|
|
|
all_characters() {
|
|
|
|
|
|
tac "$history_file"
|
2023-10-06 10:50:31 +02:00
|
|
|
|
cat ${kaomoji-file} ${unicode-file} ${emoji-flags-file}
|
2022-08-21 01:03:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
chosen=$(all_characters | awk '!seen[$0]++' | dmenu -p unicode -i -l 10 | tee --append "$history_file" | sed "s/ .*//")
|
2021-03-04 18:54:48 +01:00
|
|
|
|
|
2022-03-10 21:52:12 +01:00
|
|
|
|
[ "$chosen" != "" ] || exit
|
2021-03-04 18:54:48 +01:00
|
|
|
|
|
2022-03-10 21:52:12 +01:00
|
|
|
|
echo "$chosen" | tr -d '\n' | xclip -selection clipboard
|
2021-03-04 18:54:48 +01:00
|
|
|
|
|
2022-03-10 21:52:12 +01:00
|
|
|
|
if [ -n "$1" ]; then
|
|
|
|
|
|
xdotool key Shift+Insert
|
|
|
|
|
|
else
|
|
|
|
|
|
notify-send --app-name="$(basename "$0")" "'$chosen' copied to clipboard." &
|
|
|
|
|
|
fi
|
|
|
|
|
|
''
|