Jump to content
ian_989

Alfred Maestro - Keyboard Maestro Integration For Alfred

Recommended Posts

Alfred Maestro

Possibly the last workflow you will ever need for system tasks

 

I recently started using Keyboard Maestro (KM), and so far I love it. So I made this workflow to allow you to execute any KM macro straight from Alfred. 

 

screen.png

 

Downloads

- My Site: http://iansinnott.com/blog/integrating-alfred-and-keyboard-maestro/

- GitHub: https://github.com/iansinnott/keyboard-maestro-alfred

 

Basic Usage

Type 'km' followed by the name of the macro you want to trigger. 

 

Dependencies

 

Keyboard Maestro

 

More Info

Check out the readme in my Github repo linked above. Also, check out my blog post about these two apps if your interested in how I actually use it. That's also linked above as the first download link. 

 

Quick Note: I only tested this on the latest version of php (5.5.5 as of this writing). This is not the standard installed version that comes with new Macs, so if you have any trouble with the workflow let me know. 

 

Cheers,

Ian

Edited by ian_989

Share this post


Link to post

What parts of php are you using? I can't remember everything that comes compiled into the native php5-cli binary (5.3 pre-Mavericks and 5.4 Mavericks).

 

It looks like the 5.4 on Mavericks has curl, openssl, bzip, zip, gzip, mysql, mysqlnd, mysqli, sasl, soap, pcre-regex, and libxml among other things, and I think that the old 5.3 had a similar recipe (although I'd have to find a machine running that in order to check), so it probably doesn't have to do anything with that.

 

Other possibilities: need to turn on accessibility for KM (I really hate how Apple re-did this for Mavericks). Deprecated php functions that are throwing errors rather than just warnings.

 

Just some thoughts...

Share this post


Link to post

Yeah I heard from someone else that they were having an issue, so I'm going to check it out. I'll post an update here if I find anything and update the workflow. 

Share this post


Link to post

Is it possible to see a list of the triggers that I have in KeyboardMaestro after typing "km"?

 

I am using the workflow under Mavericks.

 

It works but I have to write:

km + "the exact name of the trigger"

 

...and I never remember the exact name of the trigger

Share this post


Link to post

I just updated the workflow. I updated it at both of the links in my original post, so just re-download it from wherever you did the first time if you were having trouble. 

 

@raguay.customct, I think the update may solve your problem.

 

Hey @rspike12, that's strange as it is indeed supposed to show all macros by simply typing in 'km'. It does on my system, and now that I just fixed a compatibility issue I don't think it's that either. Maybe an alfred specific setting? If you open up the script filter window make sure that 'with space' is checked after the keyword box and then the dropdown is set to 'argument optional'. 

Share this post


Link to post

I'm on Mavericks with php 5.4.17.  Getting the dreaded XML Parse Error:

 

Alfred 2[8622]: [ERROR] Script XML Parse Error occured Error Domain=NSXMLParserErrorDomain Code=4 "The operation couldn’t be completed. (NSXMLParserErrorDomain error 4.)" UserInfo=0x618000266740 {NSXMLParserErrorColumn=1, NSXMLParserErrorLineNumber=1, NSXMLParserErrorMessage=Document is empty
}

Share this post


Link to post

Bummer. Seeing the same error on Mavericks when triggering the macro. PHP 5.4.17, Alfred 2.1.1:

 

 

12/4/13 5:55:17.479 PM Alfred 2[378]: [ERROR] Script XML Parse Error occured Error Domain=NSXMLParserErrorDomain Code=4 "The operation couldn’t be completed. (NSXMLParserErrorDomain error 4.)" UserInfo=0x60000027f500 {NSXMLParserErrorColumn=1, NSXMLParserErrorLineNumber=1, NSXMLParserErrorMessage=Document is empty

}

Share this post


Link to post

Hey, thanks for the feedback. Glad to hear it's working for many of you. 

 

@macdrifter Thanks for opening an issue on GitHub, that brought this to my attention. 

 

For anyone with this 'XML parse error' issue try reinstalling and giving it another go. I wasn't able to find anything too specific about this issue, other than the fact that it manifests in other workflows as well. I'm hoping the update I just pushed will solve the issue for this particular workflow. Make sure to download it from GitHub, as I haven't updated the link on my own site yet: 

 

Updated Workflow: https://github.com/iansinnott/alfred-maestro

Share this post


Link to post

Hey, thanks for the feedback. Glad to hear it's working for many of you. 

 

@macdrifter Thanks for opening an issue on GitHub, that brought this to my attention. 

 

For anyone with this 'XML parse error' issue try reinstalling and giving it another go. I wasn't able to find anything too specific about this issue, other than the fact that it manifests in other workflows as well. I'm hoping the update I just pushed will solve the issue for this particular workflow. Make sure to download it from GitHub, as I haven't updated the link on my own site yet: 

 

Updated Workflow: https://github.com/iansinnott/alfred-maestro

The usual cause of such an error message is some part of your code sending output to STDOUT (usually an errant echo/print statement). That output gets mixed in with the XML, making it invalid.

(That's assuming your using a proper XML library to generate the output, not generating it in your own code.)

Edited by deanishe

Share this post


Link to post

Hi,

 

Thank you for this workflow. I'm just starting out with both Alfred and Keyboard Maestro.

 

The workflow was not showing any KM macros when typing 'km'.. I ended up having to comment out your argv check, and it is working how I think it should, showing all KM Macros when typing 'km' in Alfred.

 

Just commented out the two lines here:

https://github.com/iansinnott/alfred-maestro/blob/master/main.php#L34-L35

 

With the control flow as it was, it was exiting there.. so there was no chance for the list to populate by reaching the 'else' case at the end of the script.

 

 

 

-

Share this post


Link to post

If you replace code: 

 

  $macros[] = $macro;

 

with 

 

if (strpos($macro['name'], 'alfredhide') === false) 
{
   $macros[] = $macro;
}
 
Then you can hide macros from being displayed on alfred if you add "alfredhide" to their names. Useful if you have macros that are executed only from within other macros. 
 
Cheers

Share this post


Link to post

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
×