wrjlewis / notion-search-alfred-workflow

An Alfred workflow to search Notion with instant results
GNU General Public License v3.0
819 stars 43 forks source link

Add Support to Open Search Results in New Window (Notion for MacOS) #73

Open nelsonestrada5 opened 1 year ago

nelsonestrada5 commented 1 year ago

Is your feature request related to a problem? Please describe. I constantly have multiple Notion windows open at the same time, but when i usw the ns alfred workflow, the selected result is opened in the most recently used Notion window (which is typically a notion page I want open). It would be great to have the ability to open search results in a new tab or window so that they can be complementary to the existing open tabs.

Describe the solution you'd like The ideal solution would add another Workflow Environment Variable that is a boolean (e.g. openResultInNewWindow) that can be set by the user. When the user sets this to True, the search result selected would open a new window in the Notion Mac app.

Describe alternatives you've considered This request, of course, works out of the box when useDesktopClient is set to false, but I much prefer the Notion Mac app.

Additional context Thank you SO much for the workflow, it's already been such a productivity hack and a timesaver, so thank you!!

wrjlewis commented 1 year ago

Great suggestion and thanks for raising, I'm not sure if this is possible though. The workflow provides Alfred with a URL to open, when useDesktopClient is True the URL is notion://www.notion.so/[page]. Alfred/MacOs takes care of the rest and uses that info to open the Notion desktop which is presumable registered with notion://

Someone with more knowledge may be able to say if it is possible to tell the Notion app at the same time, to open a new window

svenko99 commented 2 months ago

You can open a page in a new tab using AppleScript (Run NSAppleScript):

on alfred_script(q)
  tell application "Notion" to activate
  tell application "System Events"
    tell process "Notion"
        -- Click "New Tab" in the "File" menu
        click menu item "New Tab" of menu "File" of menu bar 1

        -- Delay to ensure the new tab is opened
        delay 0.9

        -- Open the specific link in the new tab
        tell application "Notion" to open location q
    end tell
end tell
end alfred_script

The q is the URL of the page (notion://www.notion.so/[page]).

wrjlewis commented 2 months ago

That is good to know, thank you. I'll test this out and hopefully include in a future release.

svenko99 commented 1 month ago

Recently Notion has updated the functionality of opening a new tab. To make sure the provided script works the New Tab Search must be toggled off.

Screenshot 2024-06-15 at 12 20 29@2x