wrjlewis / notion-search-alfred-workflow

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

Notion Title Search & working with Notion Desktop #8

Closed johnathanz closed 4 years ago

johnathanz commented 4 years ago
johnathanz commented 4 years ago

@wrjlewis I did run into an issue with trying to open a "New Window" for every Text / Title Search - so Search Results don't take over whatever Notion Note the user is working on (because "Back" doesn't work)

Tried this: 1) with AppleScript direct - fails because Alfred adds trailing white space??

  set theQuery to item 1 of argv

    tell application "System Events" to tell process "Notion"
        click menu item "New Window" of menu 1 of menu bar item "File" of menu bar 1
    end tell

  return theQuery
end run

image

2) So tried a Python Run Script (which opens 2 New Windows 🤯)

import sys
from subprocess import Popen, PIPE

query = sys.argv[1]

script = '''
    # activate application "Notion"
    tell application "System Events" to tell process "Notion"
        click menu item "New Window" of menu 1 of menu bar item "File" of menu bar 1
    end tell'''

p = Popen('osascript', stdin=PIPE, stdout=PIPE, stderr=PIPE)
p.communicate(script)

sys.stdout.write(query)

Any idea what the issue is Will?

wrjlewis commented 4 years ago

Hmmm I'm unsure what is causing your issue with the app not opening a new window when you are referred by Alfred. This isn't an issue with the webapp.

I wouldn't have thought this is an issue with the trailing whitespace, probably something to do with the internal logic in the notion app itself. Do you have other instances where the app is able to open a new window from a link that isn't from alfred but outside the notion app?

wrjlewis commented 4 years ago

I'm making some changes to the repo and code to move everything into a python script which will allow for easier diffs and version control. I'm going to add some of the changes I mentioned above.

johnathanz commented 4 years ago

Hi Will, thanks for taking the time to correct my changes.

I learnt a few things 😛

I think the way you've got the Workflow now is really good 👏

wrjlewis commented 4 years ago

Thanks Johnathan!