Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge - Workspaces (or windows) search #48

Open
junho85 opened this issue Apr 5, 2024 · 0 comments
Open

Edge - Workspaces (or windows) search #48

junho85 opened this issue Apr 5, 2024 · 0 comments

Comments

@junho85
Copy link

junho85 commented Apr 5, 2024

The Edge browser has a Workspaces feature. It would be nice to have the ability to search for a workspace and navigate to it. If it's hard to search for just a workspace, I guess a window search would be fine.

example)

list-workspaces.js

#!/usr/bin/env osascript -l JavaScript

function run(args) {
  let browser = args[0];
  if (!Application(browser).running()) {
    return JSON.stringify({
      items: [{
        title: `${browser} is not running`, subtitle: `Press enter to launch ${browser}`,
      },],
    });
  }

  let chrome = Application(browser);
  chrome.includeStandardAdditions = true;

  let items = [];

  for (let window in chrome.windows) {
    let windowId = chrome.windows[window].id();

    items.push({
      title: chrome.windows[window].title(),
      arg: `${windowId}`,
    });
  }

  return JSON.stringify({items});
}

focus-workspace.js

#!/usr/bin/env osascript -l JavaScript

function run(args) {
  ObjC.import("stdlib");
  let browser = $.getenv("browser");
  let query = args[0];
  let [arg1] = query.split(",");
  let windowId = parseInt(arg1);

  focusWindow(browser, windowId);
}

function focusWindow(browserName, windowId) {
  let chrome = Application(browserName);
  chrome.includeStandardAdditions = true;

  let window = chrome.windows.byId(windowId);
  window.visible = true;
  window.index = 1;
  chrome.activate();
}
@junho85 junho85 changed the title Edge - Workspaces (windows) Edge - Workspaces (or windows) search Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant