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

Can't always get the title of iTerm window when maximized #369

Open
denvaar opened this issue Aug 11, 2022 · 1 comment
Open

Can't always get the title of iTerm window when maximized #369

denvaar opened this issue Aug 11, 2022 · 1 comment

Comments

@denvaar
Copy link

denvaar commented Aug 11, 2022

I don't think this is necessarily a dragonfly bug, but I wanted to at least mention it here since it might affect people.

I'm not sure if it's an iTerm issue, or something with Applescript itself, but I noticed that sometimes AppContext fails to match the title of the window, because the value was being set to "msng", which means "missing" according to this.

I logged what this gives in both situations where the iTerm window is not full screen vs when it is full screen.

Not full Screen

{'minW': 'msng', 'orie': 'msng', 'posn': [-31, -631], 'axds': 'msng', 'rold': 'standard window', 'focu': False, 'titl': 'app:nvim ext:py mode:n', 'ptsz': [1506, 583], 'help': 'msng', 'ects': [], 'enaB': 'msng', 'maxV': 'msng', 'role': 'AXWindow', 'valL': 'msng', 'sbrl': 'AXStandardWindow', 'selE': 'msng', 'pnam': 'app:nvim ext:py mode:n', 'desc': 'standard window', 'pcls': 'cwin'}

Full Screen (pnam missing)

{'minW': 'msng', 'orie': 'msng', 'posn': [0, 0], 'axds': 'msng', 'rold': 'window', 'focu': False, 'titl': '', 'ptsz': [1728, 37], 'help': 'msng', 'ects': [], 'enaB': 'msng', 'maxV': 'msng', 'role': 'AXWindow', 'valL': 'msng', 'sbrl': 'AXUnknown', 'selE': 'msng', 'pnam': 'msng', 'desc': 'window', 'pcls': 'cwin'}

Next, I tried to use the latest version of py-applescript to see if it made a difference, and it did not.

I also tried to run the Applescript code manually via the editor, and found that it also produced missing values. You can see from these screenshots that there is missing info when the iTerm window is maximized.

image

image


I don't know anything about Applescript, but maybe there's a more reliable way to query this kind of information. Or maybe there's just a bug with iTerm. For now I just added a hack that works well enough for my needs.

# windows/darwin_window.py

    def _get_window_text(self):
        title = self.get_properties().get('pnam')

        if title != 'msng':
            return title

        script = '''
tell application "iTerm"
            tell current window
                get name
            end tell
        end tell
        '''
        hack = applescript.AppleScript(script).run()
        return hack

I'm on Monterey 12.5. I have another machine with a previous macOS version and it doesn't happen there.

Thanks

@drmfinlay
Copy link
Member

drmfinlay commented Aug 14, 2022 via email

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

2 participants