Load workspace, action, keyboard from another app?

I’m wondering how people work with “modules” from other apps. For instance, I’d like to use shortcuts to open a particulr draft, with a workspace, and action group, and keyboard row pre loaded. I sort of wish these things were their own attributes on a url scheme, rather than separate commands that can’t be invoked at once.

Basically, I guess I see two options:

  • try to use x-success to load 4 url commands in succession for opening a draft, workspace, action group, and keyboard
  • create a script that opens all those and call the script with the run action url scheme.

What do others do here?

Probably best to write an action that configured the environment the way you wanted, and call that with the “Run Drafts Action” shortcut step. Something like:

let ws = Workspace.find("My Workspace");
app.applyWorkspace(ws);

let group = ActionGroup.find("My Group");
app.loadActionGroup(group);

let keyboard = ActionGroup.find("My Keyboard");
app.loadKeyboardActionGroup(keyboard);

// anything else you might want to change, like:

// load first draft in the workspace...
let drafts = ws.query("inbox");
if (drafts.length > 0) {
    editor.load(drafts[0]);
}

// enter focus mode
editor.focusModeEnabled = true;

Thanks Greg, that’s a good script. I like that bit about loading the first draft in the workspace.

Hi @agiletortoise

I don’t have enough javascript knowledge to know if this is a typo in the script, a typo in documentation, or a bug in the app, but your script gives this error:

Script Error: TypeError: Workspace.query is not a function. (In 'Workspace.query("inbox")', 'Workspace.query' is undefined)
Line number: 13, Column 29 

Oops, edited the example. Should be ws.query.

1 Like