34 lines
769 B
Python
34 lines
769 B
Python
|
import subprocess
|
||
|
import os
|
||
|
import json
|
||
|
|
||
|
|
||
|
def show_command_out(command: str) -> str:
|
||
|
return subprocess.check_output(
|
||
|
command,
|
||
|
shell=True
|
||
|
).decode("utf-8")
|
||
|
|
||
|
|
||
|
def main():
|
||
|
path = os.path.dirname(os.path.realpath(__file__))
|
||
|
with open(f"{path}/dictionary.json") as file:
|
||
|
dictionary = json.load(file)
|
||
|
dictionary_list = [x for x in dictionary]
|
||
|
|
||
|
key = show_command_out(
|
||
|
'echo "{}"\
|
||
|
| dmenu -l 20 -p \"Select alias\"'.format(''.join([f'{x}\n' for x
|
||
|
in dictionary_list])[:-1])
|
||
|
).strip()
|
||
|
|
||
|
try:
|
||
|
out = dictionary[key]
|
||
|
except KeyError:
|
||
|
return
|
||
|
os.system(f"echo \"{out}\" | xclip -selection clipboard -r")
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
main()
|