Jump to content
limitedheadroom

Caffeinate Control - El Capitan & Alfred 3

Recommended Posts

I used this workflow all the time on my laptop so I could prevent it from sleeping when running shows at work.  Possibly one of the most useful workflows I have but now with a new computer and therefore forced to upgrade to El Capitan it no longer works.

 

I'm also using Alfred 3 now, I don't know if that would make a difference. 

 

I simply don't understand how it works, while I'm perfectly able to go into terminal and activate or deactivate caffeinate I can't see how the workflow does it's thing so modifying it to work with OSX 10.11 is beyond me.

 

Is anyone able to help?

Share this post


Link to post

I also got this problem after updating to Alfred 3 - the Caffeinate Control workflow just stopped working.

 

In the meantime, I've downloaded KeepingYouAwake and made a small workflow to toggle it on/off.

 

It works well, but I'd prefer to go back to Caffeinate Control as it doesn't require any third-party software.

 

Hopefully the workflow gets fixed soon!

Share this post


Link to post

+1

 

I upgraded to Alfred 3 on my MacBook Air running El Capitan – the Caffeinate workflow is still working fine.

 

However, yesterday I did a clean install of my Mac mini – also El Capitan and Alfred 3 – and the Caffeinate workflow doesn't work at all. It doesn't even remember the settings I specify under "Configure Caffeinate Control".

 

Maybe the developer could chime in? It has barely been 24h and I already miss the ease of use of the workflow and had to revert back to a menu bar app… :-/

Share this post


Link to post

In most cases like this, the reason it works for some and not others is because the workflow has Alfred 2's directories hard-coded in it. If you still have your Alfred 2 directories (in ~/Library), it works. If not, it doesn't.

 

You probably just need to open up the workflow's source code in an editor and change any occurrence of "Alfred 2" to "Alfred 3".

Edited by deanishe

Share this post


Link to post

In most cases like this, the reason it works for some and not others is because the workflow has Alfred 2's directories hard-coded in it. If you still have your Alfred 2 directories (in ~/Library), it works. If not, it doesn't.

 

You probably just need to open up the workflow's source code in an editor and change any occurrence of "Alfred 2" to "Alfred 3".

 

That did the trick. There were 2 files in the workflow directory that had a couple hardcoded references to "Alfred 2" - changing them to "Alfred 3" fixed it. Thanks!

Share this post


Link to post

That did the trick. There were 2 files in the workflow directory that had a couple hardcoded references to "Alfred 2" - changing them to "Alfred 3" fixed it. Thanks!

 

 

How did you achieve this? Is there a step-by-step procedure available anywhere? How does one edit a pre-existing workflow?

Share this post


Link to post

How did you achieve this? Is there a step-by-step procedure available anywhere? How does one edit a pre-existing workflow?

 

There may be a better way to do this, but this is what I did, and now the Caffeinate Control workflow works for me.

I tried to make a step-by-step guide for you. Hope it helps!

 

Step 1

Open up Alfred Preferences and go to the Workflows tab

In your list of workflows, right click "Caffeinate Control" and do Open in Finder, like this:

 

TdXXCq6.png

 

Step 2

Now you should have a Finder window open to the Caffeinate Control workflow directory, like this:

 

76dQx8g.png

 

I have highlighted the 2 files you will be editing: conf-and-help.scpt and library.sh

 

Step 3

Open conf-and-help.scpt, which will launch the Script Editor

Search for "Alfred", and you will find this line:

 

UHMd94a.png

 

Yours will say Alfred 2, so change it to Alfred 3 like in mine

Save the script and quit the Script Editor

 

Step 4

Open library.sh in a text editor (I used Sublime Text, but TextEdit or any other text editor is fine)

Search for "Alfred", and you will find these 2 lines:

 

Q03Jxxf.png

 

Yours will say Alfred-2 and Alfred 2, so change them to Alfred-3 and Alfred 3 like in mine

Save the file and quit your text editor

 

That's it! Now the Caffeinate Control workflow should be working again  :)

 

(Note: after completing these steps, you might have to quit Alfred and then restart Alfred, but I'm not sure if that's necessary - I can't remember if I had to do that or not, but if it's still not working for you, then try that.)

Share this post


Link to post

(Note: after completing these steps, you might have to quit Alfred and then restart Alfred, but I'm not sure if that's necessary - I can't remember if I had to do that or not, but if it's still not working for you, then try that.)

 

 

It should never be necessary to restart Alfred after changing a workflow unless your workflow has serious bugs and quitting Alfred is the only way to stop it.

Share this post


Link to post

Damn. Just report these bugs to me, and I'll take care of them. This is an insanely old workflow that existed before the environmental variables were introduced, so I had to hardcode the paths. I'll update them.

Share this post


Link to post

Damn. Just report these bugs to me, and I'll take care of them. This is an insanely old workflow that existed before the environmental variables were introduced, so I had to hardcode the paths. I'll update them.

 

 

Wouldn't have helped with the app name in the AppleScript though :(

Share this post


Link to post

Wouldn't have helped with the app name in the AppleScript though :(

 

That's exactly what I'm debugging right now... trying to get the system variable and convert it to a path in AS. Damn, it's been a while since I've touched AS.

Share this post


Link to post

Forget it. You can't. (Well, I couldn't figure it out). You can't use a variable as the target of a tell and if you include tell Alfred 2 and tell Alfred 3 in the same script, it'll complain if both apps aren't installed and ask the user to locate the missing one :( 

 

I think you have to either use duplicate scripts with the number changed or rewrite in JS, where you can use a variable in var app = Application('Alfred ' + version)

Or generate the AppleScript using a proper language.

Edited by deanishe

Share this post


Link to post

The AS just runs a quick pop-up for the configuration, so that problem does not apply. There is no tell Alfred 2 or Alfred 3 in there (unless I'm totally forgetting something from code that I wrote three years ago -- total possibility).

 

(Although you could get around that problem by checking to see if they are installed, and wrapping the tell statements in an if, etc...)

Share this post


Link to post

Crap. So I need to get back to work (deadline tomorrow; needing to do crap over the weekend). And I didn't manage to refresh my AS quick enough to fix the AS in the configure script. I'll get back to that after I push the final changes on the work deadline.

 

For now, I pushed some changes to the git repo; but I need to get on an old computer with Alfred 2 in order to export it and not break others' installations. Will do that and post here after I fix the AS problem.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...