Created
February 22, 2019 01:13
-
-
Save outloudvi/9d34fd0f518cb996d5883d962d203252 to your computer and use it in GitHub Desktop.
A wrapper for wudao-dict with the enhancement of notify-send.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# You may want to link it to /usr/bin then KDE can use it. | |
import re | |
from subprocess import run, check_output, DEVNULL | |
import sys | |
ansi_escape = re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]') | |
result = check_output( | |
['/usr/bin/wd','-s',sys.argv[1]] | |
).decode() | |
escaped = ansi_escape.sub('', result) | |
groups = escaped.split('\n') | |
run( | |
['notify-send',groups[0],'\n'.join(groups[1:])], | |
stdout=DEVNULL, | |
stderr=DEVNULL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment