Answer the question
In order to leave comments, you need to log in
Running a bash script with a hotkey?
The situation is as follows: there is Linux Mint, there is a script, you need to run the script by pressing "Ctrl + T". It starts once, does its job and turns off.
If interested, the script code
#!/bin/sh<br>
n=0<br>
clip=$(xsel -o)<br>
if ; then<br>
clip=$(wget -U "Mozilla/5.0" -qO - "http://translate.google.com/translate_a/t?client=t&text=$(echo $clip | sed "s/[\"'<>]//g; s/&/%26/g")&sl=auto&tl=ru" | sed 's/\[\[\[\"//' | cut -d \" -f 1)<br>
notify-send "$clip" "en->ru"<br>
n=1<br>
elif ; then<br>
clip=$(wget -U "Mozilla/5.0" -qO - "http://translate.google.com/translate_a/t?client=t&text=$(echo $clip | sed "s/[\"'<>]//g; s/&/%26/g")&sl=auto&tl=en" | sed 's/\[\[\[\"//' | cut -d \" -f 1)<br>
notify-send "$clip" "ru->en"<br>
n=1<br>
elif ; then<br>
clip=$(echo $clip | sed 's/\#//g')<br>
notify-send "#$clip" "#$clip"<br>
n=1<br>
fi<br>
if ; then<br>
clip=$(wget -U "Mozilla/5.0" -qO - "http://translate.google.com/translate_a/t?client=t&text=$(echo $clip | sed "s/[\"'<>]//g; s/&/%26/g")&sl=auto&tl=ru" | sed 's/\[\[\[\"//' | cut -d \" -f 1)<br>
notify-send "$clip" "*->ru"<br>
fi<br>
Answer the question
In order to leave comments, you need to log in
Your script is not where the system is looking for it. Put it in /usr/bin/, write the “translate” command in hotkeys, without .sh and other things.
[ -d "$HOME/bin" ] && PATH="$HOME/bin:$PATH"
.profile
or .bash_profile
not this line, then add it and create a directory ~/bin
. You need to either re-login or re-read the settings with the command source ~/.profile
. After that, the system will see scripts from bin. Alternatively, you can specify the full path to the script.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question