-
Notifications
You must be signed in to change notification settings - Fork 0
/
select-unicode-char
executable file
·49 lines (40 loc) · 1.01 KB
/
select-unicode-char
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
# Author: Jan Larres <[email protected]>
# License: MIT/X11
import sys
import unicodedata
from subprocess import CalledProcessError, run
UNICODE_END = 0xE01EF
def main() -> int:
chars = [
c + "\t" + name
for c, name in (
(c, unicodedata.name(c, None)) for c in map(chr, range(0x0, UNICODE_END))
)
if name is not None
]
stdin = "\n".join(chars)
try:
p = run(
["rofi", "-dmenu", "-i"],
input=stdin,
text=True,
check=True,
capture_output=True,
)
except CalledProcessError:
return 1
selected = p.stdout.splitlines()[0].split("\t")[0]
try:
p = run(
["xclip", "-i", "-selection", "clipboard"],
input=selected,
text=True,
check=True,
)
except Exception as e:
run(["rofi", "-e", str(e)], check=True)
raise
return 0
if __name__ == "__main__":
sys.exit(main())