Skip to content

Instantly share code, notes, and snippets.

@sharpicx
Last active May 16, 2023 11:47
Show Gist options
  • Save sharpicx/c7c65787a3191800221c0df37c4f19d6 to your computer and use it in GitHub Desktop.
Save sharpicx/c7c65787a3191800221c0df37c4f19d6 to your computer and use it in GitHub Desktop.
import subprocess
import mtranslate
import clipboard
def translateNow(argv, dest="id"):
return mtranslate.translate(argv, dest)
def main():
text = translateNow(clipboard.paste())
try:
if text == "":
subprocess.run("dunstify 'Translation' 'clipboard is bout to get heal, try again if it has a content'", shell=True)
else:
subprocess.run(f'dunstify "English -> Indonesian" "{text}"', shell=True)
except Exception as i:
subprocess.run(f'dunstify "Translation" "error"', shell=True)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment