I have a python script to translate text via command line, the usage is
script.py "Hola Mundo" and the output will be
Now I want to send text to this program via a keyboard shortcut in Xubuntu 18.04.1 XFCE, so I've written a bash script
translate.sh and put it together with
/usr/local/bin, and assigned a keyboard shortcut with XFCE keyboard utility to it. However, everything inside the bash script worked, except the line which calls Python.
If I call the script via terminal, it will work flawlessly. I am still very new to bash, and don't know how to get the error message of Python (if any) printed out, when I'm calling the bash script via XFCE keyboard shortcut.
Anyone have an idea what is happening and what the problem is?
My bash script
#!/usr/bin/env bash TEXT=`xsel -o` RESULT=`python /usr/local/bin/script.py "$TEXT"` # or RESULT=`script.py "$TEXT"` (I've put shebang in the python script too) # neither worked with keyboard shortcut, both worked in terminal echo $RESULT # for debugging in terminal notify-send --icon=info "$TEXT" "$RESULT"
Note that if I run this script in the terminal, everything works - the notification pops up, and I can see the result echoed in the terminal too. When calling this script with keyboard shortcut, the popup appears with the selected text as the notification title, but there's no body. (Proving only the python line didn't work.)
The shebang line in the Python script is