6

I am a huge fan of the terminal-based music player cmus. It does everything I want from a music player and nothing I don't. I want to use it instead of iTunes on my Macbook. I installed it via homebrew and it's working great, except for one thing...

I'm trying to set up a system hotkey to play/pause cmus even if it's not focused. cmus provides a command-line program to help you do this.

cmus-remote --pause

Running that from anywhere will connect to the running cmus instance via a socket and issue the play/pause command.

So I'm trying to set up a system hotkey to run that command and play/pause cmus. As suggested in another answer, I've tried creating an Automator service workflow that runs the script. So hotkey starts the Automator service which runs the shell script which runs cmus-remote.

This workflow works perfectly in the GUI, but fails when run as a service

Now here's the real problem:

This Automator workflow works perfectly when I run it from the Automator edit interface, but it always fails when I try to run it as a service. The error message contains no useful information, just "The action “Run Shell Script” encountered an error."

I've attempted to put some debugging output into my script:

echo "AUTOMATION STARTED" >> ~/automation.txt
/usr/local/bin/cmus-remote --pause 2>&1 >> ~/automation.txt

When I read that file, all I see is:

AUTOMATION STARTED

Clearly the workflow is starting and running, and it's the cmus-remote command itself that is failing.

So...

  1. Why this would cmus-remote work inside the Automator GUI, but die mysteriously outside of it?
  2. Is there anyway to get more failure info out of cmus?
  3. Are there open-source alternatives to Automator for binding system hotkeys to simple shell commands?
1

I think there is a security setting in Mavericks (and possibly Mountain Lion) that causes Automator not to allow system control. See this question

Open your Console and watch the logs when you run the service. In my case, it crashes when I try to run a shell script.

I tried adding Automator to the Security and Privacy preferences, but it did not solve the issue.

As a work around, you may have to use applescript to create and app, tie that to a service, and add the app to the Privacy tab of your Security and Privacy preference pane.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .