Skip to content

fetching titles on macOS #30

Description

@exoji2e

#29 is replacing the logic for retrieving windowtitle and active app from macOS clients.

There seems to be lots of options on how to do this, and we should definitely replace the applescript.

I just want to share a bit of what I found out.

The nicest way for us to do this is probably through python and AppKit.

I can easily get the active application by:

from AppKit import NSWorkspace
workspace = NSWorkspace.sharedWorkspace()
app_name = workspace.frontmostApplication().localizedName()

This gist tries to do what we want.

However, it does not work all the time for me, since window['kCGWindowOwnerName'] == 'iTerm', while app.localizedName() == 'iTerm2'. Also, it seems that the gist is just returning the first match. Maybe windowList is always sorted in the correct order, not sure.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions