Jump to content

Updating variables set in Configuration builder


Recommended Posts

Posted

What's the best way of updating the variables set by the configuration builder? I want to update these variables through a keyword flow.

 

The following method will work (I think), but I'm unsure if it's the "right" way:

 

check if prefs.plist exists

if yes, check if variable is set here and update the value if it is

otherwise update the value in info.plist

Posted

If you edit the info.plist you’ll be changing the default value, defeating the purpose. You should never edit the plists directly. If you need to edit a configuration value programatically—and in most cases you shouldn’t, the Configure Workflow… button exists so users can edit the values—use the set configuration AppleScript. See Alfred’s AppleScript dictionary.

Posted
3 hours ago, vitor said:

If you edit the info.plist you’ll be changing the default value, defeating the purpose. You should never edit the plists directly. If you need to edit a configuration value programatically—and in most cases you shouldn’t, the Configure Workflow… button exists so users can edit the values—use the set configuration AppleScript. See Alfred’s AppleScript dictionary.

Thank you:) I understand that this isn't the norm. I'm working on a workflow that talks to Kubernetes clusters and it's very useful to be able to quickly switch between clusters (context in k8s lang). I could possibly set this up without a configuration variable, but I feel this is the cleanest way of doing it, as it makes sure the "default" context is set when the workflow is initially installed.

Leaving this here for the others that might also need this:

on run argv
  set theQuery to item 1 of argv
  set bundleID to (system attribute "alfred_workflow_bundleid")
  tell application id "com.runningwithcrayons.Alfred"
  set configuration "kube_context" to value theQuery in workflow bundleID with exportable
  end tell
  return theQuery
end run

Here "kube_context" is the configuration variable.

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