Jump to content

Alfred profiles? Global shortcut to enable workflows?


Recommended Posts

Hi,

 

Problem: I sometimes need to help family or friends with some stuff on their MBP. However, I'm much more efficient if all my usual Alfred workflows works. However my friends/family wouldn't want to have those workflows enabled all of the time.

 

What I'm looking for: A global shortcut or Alfred workflow to enable/disable a set of Alfred workflows. I don't see any way to do it in Alfred itself, unfortunately. BetterTouchTool allows for a global shortcut to enable a specific profile, which is genius; with one keystroke I can enable a set of keyboard shortcuts that work for me when I use the computer.

 

 

Any suggestions?

Link to comment

You may be able to do this by copying the uncompressed workflows to their Alfred directories.

 

Say they sync their Alfred preferences to ~/Dropbox/Alfred.alfredpreferences. Inside ~/Dropbox/Alfred.alfredpreferences/workflows there are a bunch of directories for all the uncompressed workflows. If you add or remove other workflows to and from there, you’ll see they are actually updated in Alfred itself1.


So you can make them a workflow that has all of yours, and when you issue your command it’ll just copy them to the appropriate directory. Issue another command and you remove them.


You can also try replacing the entire Alfred.alfredpreferences at once, and all your setting would be ported over. That might be the fastest/easiest one to accomplish, but I’m not sure if it’d work flawlessly.

 



1 I’ve done it successfully with single workflows in the past. Never tried it with a bunch of them at once.

Edited by vitor
Link to comment

Thanks for the suggestions.

 

It seems like the system responds within ~10 seconds when you move the workflows in/out of the folder. Not ideal, but an acceptable solution if nothing better comes up.

 

1. Do you know how the naming scheme e.g. "user.workflow.FA536ACA-8101-4A71-90ED-2B54B90672E6" is decided? Is it some kind of hash value from the workflow title and contents? So I could assume that this name will very likely not collide with some other workflow name?

 

3. However besides just the workflow, I'd actually all of the Alfred stuff (snippets, resources, features etc.) to be easily toggled. I did try to move the whole folder, but that didn't seem to work well (or at all). I just don't know what copy and what to leave inside the Alfred.alfredpreferences package. I want to move as much as possible, but at the same time, it should work reliably. Since moving just "workflows" worked semi-well, and all of Alfred.alfredpreferences didn't work at all, I don't know how much trial and error I'm willing to through. Any suggestions?

 

3. Finally I also looked for the "Advanced" pane, in hope of digging up the "syncing folder" setting somewhere, which would supposedly solve all the problems, but I can't find it. Is it possible to set the syncing folder programmatically?

Link to comment
22 minutes ago, Fnantier said:

Do you know how the naming scheme e.g. "user.workflow.FA536ACA-8101-4A71-90ED-2B54B90672E6" is decided? Is it some kind of hash value from the workflow title and contents? So I could assume that this name will very likely not collide with some other workflow name?

 

The naming scheme is based on UUIDs by the look of the names (and UUIDs are common in macOS programming).

 

Alfred doesn't care what the folders are called, however. I have a script that renames the directories after the workflow bundle ID, and Alfred is fine with that.

 

22 minutes ago, Fnantier said:

However besides just the workflow, I'd actually all of the Alfred stuff (snippets, resources, features etc.) to be easily toggled. I did try to move the whole folder, but that didn't seem to work well (or at all). I just don't know what copy and what to leave inside the Alfred.alfredpreferences package. I want to move as much as possible, but at the same time, it should work reliably. Since moving just "workflows" worked semi-well, and all of Alfred.alfredpreferences didn't work at all, I don't know how much trial and error I'm willing to through. Any suggestions?

 

Did you restart Alfred after you replaced Alfred.alfredpreferences?

 

22 minutes ago, Fnantier said:

Finally I also looked for the "Advanced" pane, in hope of digging up the "syncing folder" setting somewhere, which would supposedly solve all the problems, but I can't find it. Is it possible to set the syncing folder programmatically?

 

There's a syncfolder key in Alfred's preferences file (~/Library/Preferences/com.runningwithcrayons.Alfred-Preferences-3.plist).

 

As long as you quit Alfred before changing it, I reckon updating that path will do the trick.

 

I'm not sure that switching the Alfred.alfredpreferences bundle will Just Work, however, as there appear to be machine-specific preferences in there, too. So some of your settings etc. won't be applied, as they aren't associated with the new machine.

 

Edited by deanishe
Link to comment
20 hours ago, deanishe said:

 

The naming scheme is based on UUIDs by the look of the names (and UUIDs are common in macOS programming).

 

Alfred doesn't care what the folders are called, however. I have a script that renames the directories after the workflow bundle ID, and Alfred is fine with that.

 

 

Did you restart Alfred after you replaced Alfred.alfredpreferences?

 

 

There's a syncfolder key in Alfred's preferences file (~/Library/Preferences/com.runningwithcrayons.Alfred-Preferences-3.plist).

 

As long as you quit Alfred before changing it, I reckon updating that path will do the trick.

 

I'm not sure that switching the Alfred.alfredpreferences bundle will Just Work, however, as there appear to be machine-specific preferences in there, too. So some of your settings etc. won't be applied, as they aren't associated with the new machine.

 

 

No I didn't restart it. That should probably work.

 

It sounds like a promising solution could be to have a script that:

1. quit Alfred

2. change sync folder in ~/Library/Preferences/com.runningwithcrayons.Alfred-Preferences-3.plist

3. launch Alfred

 

What is the easiest way to achieve this? Apple Script? Launcher via BetterTouchTool perhaps.

I don't know so much Apple Script, can anyone get me started? :-)

 

Link to comment
13 minutes ago, Fnantier said:

quit Alfred

 

AppleScript: tell application "Alfred 3" to quit.

 

13 minutes ago, Fnantier said:

launch Alfred

 

AppleScript: tell application "Alfred 3" to activate.

 

14 minutes ago, Fnantier said:

change sync folder in ~/Library/Preferences/com.runningwithcrayons.Alfred-Preferences-3.plist

 

Bash: /usr/libexec/PlistBuddy -c 'set syncfolder {{whatever your new path is}}' "${HOME}/Library/Preferences/com.runningwithcrayons.Alfred-Preferences-3.plist".

Link to comment

Thanks vitor. Well this is strange... it almost works, but doesn't:

 

1. I quit alfred

2. Change the value "syncfolder" of plist "com.runningwithcrayons.Alfred-Preferences-3.plist" the desired path. I can verify that it's been changed by opening and inspecting.

3. Launch Alfred, all my workflows etc. are still there.

4. A moment after I launch Alfred, the syncfolder property resets to it's old value. It's overwritten at launch with the old value instead of dictating new behavior.

 

Any suggestions?

Link to comment
1 hour ago, Fnantier said:

Any suggestions?

 

Yes. I forgot that macOS caches those settings, which is why this is happening. After step 2 run defaults read com.runningwithcrayons.Alfred-Preferences-3. The output of the command is irrelevant (you can even redirect it to /dev/null) it’s just required so the system sees the changed settings.

Edited by vitor
Link to comment

That works, thanks.

 

There's one final bonus feature I'm considering

Now we have done switching to a sync folder that I can specify (global hotkey achieved with BetterTouchTool).

What could be interesting would be to press another shortcut and it goes back to the previous sync folder, whatever that was. We'd have to save the value of syncfolder in the plist somewhere to do that.

 

Any suggestions? In any case, thank both of you for your help, I now have the core functionality I was looking for.

Link to comment

 

1.

I'm trying to avoid using Alfred since I'll be changing Alfred itself, and therefor can't count on having Alfred workflows available when I swap sync folder.

Can it be saved within an additional entry in com.runningwithcrayons.Alfred-Preferences-3.plist or is that risky?

 

2. If I wanted to save these Applescript and bash scripts somewhere on the disk in user space, what would an obvious place to be for? I'm thinking, not Dropbox or Google Drive since I cannot count on that being installed. I'm also thinking I wouldn't want to clutter the user folder ~/ or the ~/Documents folder, but somewhere invisible, but obvious.

Link to comment
42 minutes ago, Fnantier said:

Can it be saved within an additional entry in com.runningwithcrayons.Alfred-Preferences-3.plist or is that risky?

 

Saving your script's settings in another application's settings file is a pretty terrible idea, tbh.

 

42 minutes ago, Fnantier said:

If I wanted to save these Applescript and bash scripts somewhere on the disk in user space, what would an obvious place to be for?

 

The proper place for executable scripts is ~/bin (or maybe /usr/local/bin). The proper place for AppleScripts is ~/Library/Scripts.

 

If I were you, I'd probably wrap the whole thing up in an application using Automator and a simple AppleScript dialog box. And I'd put the application in ~/Applications.

Edited by deanishe
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...