Jump to content

Controlling ncmpcpp via Alfred 2 Workflows


Recommended Posts

I have installed mpd and ncmpcpp, controlling it via terminal is fairly easy:

ncmpcpp toggle   # Toggles play/pause

 

But when I try to make the same trick with Alfred Workflow (Trigger: Hotkey --- Action: Run Script --- Output: Post Notification) with this shell script:

 

ncmpcpp toggle

 

or

 

sh /path/to/myscript.sh
---------------------------------------------------
#!/bin/bash
ncmpcpp toggle

...only notification pops out.

Same thing happens with Automator.

 

So, how can I control ncmpcpp via Alfred 2?

Link to comment

I have installed mpd and ncmpcpp, controlling it via terminal is fairly easy:

ncmpcpp toggle   # Toggles play/pause

 

But when I try to make the same trick with Alfred Workflow (Trigger: Hotkey --- Action: Run Script --- Output: Post Notification) with this shell script:

 

ncmpcpp toggle

 

or

 

sh /path/to/myscript.sh
---------------------------------------------------
#!/bin/bash
ncmpcpp toggle

...only notification pops out.

Same thing happens with Automator.

 

So, how can I control ncmpcpp via Alfred 2?

 

Do you know where those are stored? The reason I ask is, I'm thinking this is a profile issue. By that I mean, Alfred doesn't import your user profile when running terminal commands. Therefore, certain necessary paths may not be available by default. Try providing the full path to the ncmcpp application. If it is within your home folder, use full path there as well and not ~ to represent path to your home directory.

Link to comment

 

I don't really see any issues with the bash script. The exit 0 isn't really necessary but that shouldn't prevent the script from working I wouldn't think. Looking around, I'm assuming that you installed ncmpcpp through Mac Ports? If so, did you maintain the default installation path (/opt/local/bin)? If so, the only thing I can think of is to once again try running the application from the full path. Keep it as simple as possible. For the script, just have....

/opt/local/bin/ncmpcpp toggle

 

If it still doesn't execute, check the OS X Console.app and see if you have any error there associated with trying to run ncmpcpp. This should be an extremely simple, straight forward workflow.

Link to comment

Thank you very much! I should've suggested this myself :)

I used brew, so my command looks like this:

/usr/local/bin/ncmpcpp toggle

 

And this is totally working!

 

Awesome, glad you were able to get it working. As mentioned, Alfred doesn't import your profile for when executing scripts and such. If you dropped to a terminal and did 

 

echo $PATH

 

Then I'm sure /usr/local/bin is probably in your path. However, if you made a simple workflow to echo $PATH and show the results in large type in Alfred, you would see that $PATH only includes /usr/bin:/bin:/usr/sbin:/sbin. This is why the command wasn't working. These are the defaults paths searched if you enter an executable name without the path. It wasn't finding the file and was therefore failing.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...