I would like to run a simple shell command via hotkeys. So far I've created a service via Automator wich runs the following AppleScript command:

do shell script "/bin/bash -c '/opt/local/bin/cmus-remote -n'"

and does not take any input.

It runs fine when executed from within Automator and also when called from the command line itself, but when I try to execute it as a service -- either via hotkeys or from e.g. Firefox's global menu Firefox->Services --, it fails with an unspecific error.

What do I do wrong?

Thanks in advance!

PS: Hotkey execution works fine if I use Spark, but I'd still like to know where I went wrong.

  • Why don't you Run Shell Script with /bin/bash -c '/opt/local/bin/cmus-remote -n' instead of Run Applescript with do shell script...? – jherran Nov 27 '14 at 14:13
  • I did that too... same issue. – homoludens Nov 27 '14 at 14:40

I tested with an example script and work for me when I tell the service is available in Firefox. I used this fake script to test:

echo $1 > testfile.txt

What I did is the following:

  • Save this automator service on ~/Library/Services. I called it Service Test.

enter image description here

  • Then on System Preferences → Keyboard → Shortcuts → Services assign a shortcut to the service.

enter image description here

  • Open Firefox and works both if I execute it from Services menu and using ctrl++Y.

$ cat testfile.txt


Hope that helps you.

  • It did indeed... This worked for me as well. It seems that in this case, the issue lies with the specific shell command (maybe because the cmus-remote commands listen to a UNIX socket which cannot be addressed by Apple services?) – homoludens Dec 12 '14 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.