Jump to content

Modify workflow environment variable


kwei

Recommended Posts

Hey all, I'm trying to do something pretty simple: I want to flip an environment variable between two values based on a hotkey.

 

I found this syntax for modifying my environment variable ("selector"), and it appears to work... Kind of.

 

ObjC.import('stdlib');
Application('com.runningwithcrayons.Alfred').setConfiguration('selector', {
    toValue: 'option1',
    inWorkflow: $.getenv('alfred_workflow_bundleid'),
    exportable: true
});

 

The script runs and all seems well. If I view the environment variable by clicking the [x], it's different! But if I then go to print the value of "selector" (say, using the "large type" output) it doesn't always update. It seems to switch but only after a few minutes. I want it to change immediately, and be accessible immediately.

 

Previously I was doing this without any trouble by writing to and reading from a text file – this was flawless, and would persist between different workflows as well, but I felt like I should do it the "right" way and use "real" variables. Is there any way to make this work?

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...