Ubuntu – How to run a one-line bash command with a keyboard shortcut

scriptsshortcut-keys

I just made a custom keyboard shortcut, which is to execute the following command :

if [[ `banshee --query-current-state | grep playing` ]]; then banshee --pause; else banshee --play; fi

While this works flawlessly in a terminal, when I try to run it via the shortcut I just made I get this error :

Error while trying to run (if [[ `banshee –query-current-state | grep
playing` ]]; then banshee –pause; else banshee –play; fi) which is
linked to the key (XF86AudioPlay)

What am I doing wrong ?

Best Answer

Make sure that your script is being run by Bash, since you're using Bash builtins. Try this:

bash -c 'if [[ `banshee --query-current-state | grep playing` ]]; then banshee --pause; else banshee --play; fi'