talonvoice / beta

Issue tracker for the private Talon Beta
10 stars 0 forks source link

window.title not updated in Mate #22

Closed hbk619 closed 4 years ago

hbk619 commented 4 years ago

Using Mate 1.22.2 on Mint 19.3 (Ubuntu 18.04) when you switch windows the title is not updated so code like this https://github.com/knausj85/talon_new_api_starter_pack/blob/6cc0f5c147cfba935e1817771c60eb371742ac77/actions/code.py#L20 doesn't work as you never get the new file name. Going via the old api doesn't work either e.g. https://github.com/anonfunc/talon-user/blob/master/apps/jetbrains.py#L312

Below is me switching between files in Pycharm and the terminal:

2020-02-18 17:03:34 IO Window title:.talon [~/.talon] - .../user/talon-voice/apps/jetbrains.py - PyCharm

2020-02-18 17:03:34 IO Window title:.talon [~/.talon] - .../user/talon-voice/apps/jetbrains.py - PyCharm

2020-02-18 17:03:39 IO Window title:./run.sh

2020-02-18 17:03:39 IO Window title:./run.sh

2020-02-18 17:03:39 IO Window title:./run.sh

2020-02-18 17:03:39 IO Window title:./run.sh

2020-02-18 17:03:41 IO Window title:.talon [~/.talon] - .../user/talon-voice/apps/jetbrains.py - PyCharm

2020-02-18 17:03:41 IO Window title:.talon [~/.talon] - .../user/talon-voice/apps/jetbrains.py - PyCharm

2020-02-18 17:03:41 IO Window title:.talon [~/.talon] - .../user/talon-voice/apps/jetbrains.py - PyCharm

2020-02-18 17:03:41 IO Window title:.talon [~/.talon] - .../user/talon-voice/apps/jetbrains.py - PyCharm

Switching tabs in the terminal is the same - window.title is not updated

lunixbochs commented 4 years ago

For some reason your logs are smashed together.

What’s the actual desktop environment being used? Gnome 2/3, KDE Plasma, XFCE, LXDE, etc? Is wayland being used? Talon doesn’t support wayland yet.

hbk619 commented 4 years ago

The MATE Desktop Environment is the continuation of GNOME 2

Gnome 2 it seems, edited the comment to make the log more readable, not sure why the code block ignored new lines

hbk619 commented 4 years ago

Using X11 with lightdm

lunixbochs commented 4 years ago

Can you try again in beta 1047?

hbk619 commented 4 years ago

:+1: that fixed it. When I switch focus to and away it updates. Is it expected for the context function to be called again if I keep focus? So if I flip between a js and a css file in webstorm should 'func':

ctx = Context("javascript", func=extension_context(".js"))

be triggered? Or in the talon file context https://github.com/knausj85/talon_new_api_starter_pack/blob/6cc0f5c147cfba935e1817771c60eb371742ac77/actions/code.py#L20 should 'language' be triggered again?

lunixbochs commented 4 years ago

I think both of those should work, correct. If they're not, can you check the win_title event when the filename is changing in webstorm?

from talon import ui
ui.register('win_title', print)
hbk619 commented 4 years ago

That prints correctly, changing file logs the new title

lunixbochs commented 4 years ago

Ooh, I think knausj needs to update win.file_ext to make that work properly.

hbk619 commented 4 years ago

That wouldn't effect the context/func though would it? I stole that from anonfunc's repo

lunixbochs commented 4 years ago

If win_title is firing successfully, then extension_context is probably broken for your title format, it uses some kind of string processing. Can you go put a print in extension_context and see if that code is running at all during the event?

lunixbochs commented 4 years ago

1052 should fix this for newapi (but warning if you're using knausj's scripts, it will break formatters until they have a chance to push an update)

hbk619 commented 4 years ago

Updated talon and I've got code.py and a talon.talon file from knausj, added a print(title) inside the language function and it only prints updates when the window loses focus but not when flipping between files in an IDE. Same for inside an extention_context.

Should actions be called for win_title events? Or do I need to add a listener and tell talon that something's changed?

lunixbochs commented 4 years ago

I thought I already did that.

from talon import scope
scope.register('change', print)

And see which scopes get updated when you change files.

hbk619 commented 4 years ago

Nothing on changing file, but if I switch focus:

2020-02-20 17:12:30 IO code.language 2020-02-20 17:12:30 IO app

lunixbochs commented 4 years ago

That's wild, but you get win_title updates just fine from ui.register?

hbk619 commented 4 years ago

Yeah there was no win.title scope update but I got the print from ui.register printing stuff.

On a related note gets more complicated with XFCE (4.14, X11).

I switch between terminal windows I get scope changes but no title changes (even though scope includes win.title). If I switch between files in an IDE I get title values updating but not scope events.

2020-02-21 12:32:34 IO Window(app=App(pid=8854, "Firefox"), title="window.title not updated in Mate · Issue #22 · talonvoice/beta - Mozilla Firefox") 2020-02-21 12:33:21 IO scope 2020-02-21 12:33:21 IO code.language 2020-02-21 12:33:21 IO scope 2020-02-21 12:33:21 IO app 2020-02-21 12:33:21 IO scope 2020-02-21 12:33:21 IO win.title 2020-02-21 12:33:21 IO Window(app=App(pid=7129, "jetbrains-pycharm-ce"), title=".talon [~/.talon] - .../user/talon-voice/apps/jetbrains.py - PyCharm") 2020-02-21 12:33:23 IO Window(app=App(pid=7129, "jetbrains-pycharm-ce"), title=".talon [~/.talon] - .../user/talon-voice/text/numbers.py - PyCharm") 2020-02-21 12:33:25 IO Window(app=App(pid=7129, "jetbrains-pycharm-ce"), title=".talon [~/.talon] - .../user/actions/formatters.py - PyCharm") 2020-02-21 12:33:28 IO scope 2020-02-21 12:33:28 IO code.language 2020-02-21 12:33:28 IO scope 2020-02-21 12:33:28 IO app 2020-02-21 12:33:28 IO scope 2020-02-21 12:33:28 IO win.title 2020-02-21 12:33:29 IO scope 2020-02-21 12:33:29 IO app 2020-02-21 12:33:29 IO scope 2020-02-21 12:33:29 IO win.title 2020-02-21 12:33:51 IO scope 2020-02-21 12:33:51 IO app 2020-02-21 12:33:51 IO scope 2020-02-21 12:33:51 IO win.title

Maybe I should just install Ubuntu :-D

hbk619 commented 4 years ago

An update/summary of current state:

Talon version: talon-linux-89-0.0.8.29-1185-gb4dc989 DESKTOP_SESSION=xfce (4.14) XDG_SESSION_TYPE=x11

Using repo: https://github.com/knausj85/knausj_talon

https://github.com/knausj85/knausj_talon/blob/master/code/code.py#L20 is only triggered on window focus changing

from talon import scope scope.register('change', print) is triggered only on window focus changing

from talon import ui ui.register('win_title', print) Is triggered when changing tabs in IDE or terminal. Also triggered when IDE is focused, but not other apps.

Expected behaviour: https://github.com/knausj85/knausj_talon/blob/master/code/code.py#L20 to be triggered when window title is updated (on focus change or switching between files) so that I can filter commands based on the type of file currently open

Would the recommendation be to use Ubuntu with Gnome?

lunixbochs commented 4 years ago

It's weird that scope change is only hitting on window focus, because all window events trigger the code scope update :(

hbk619 commented 4 years ago

Anything else I can do to help debug it?

lunixbochs commented 4 years ago

Try this script, it replicates how the code scope works:

from talon import ui

def scope_test():
    win = ui.active_window()
    filename = ''
    file_ext = ''
    try:
        filename = actions.win.filename()
        file_ext = actions.win.file_ext()
    except NotImplementedError:
        print('skipping actions.win.filename/file_ext, not implemented')
    print('resulting scope:', {
        'title': win.title,
        'doc': win.doc,
        'filename': filename,
        'file_ext': file_ext,
    })

ui.register('', scope_test)
hbk619 commented 4 years ago

Commented lines below is me indicating what I did, not part of the logs (hope this makes it clearer) :) I get 5 statements when I change window to Pycharm, 3 when I change to terminal and one when I switch the active file in Pycharm

Focus Pycharm

2020-03-29 16:57:31 IO resulting scope: {'title': '', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-29 16:57:31 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/code/jetbrains.py - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-29 16:57:31 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/code/jetbrains.py - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-29 16:57:31 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/code/jetbrains.py - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-29 16:57:31 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/code/jetbrains.py - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-29 16:57:31 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/code/jetbrains.py - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

Switch to different file (not jetbrains.py)

2020-03-29 16:57:35 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/code/jetbrains.py - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

Switch to different file (not jetbrains.py)

2020-03-29 16:57:40 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/code/jetbrains.py - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

Focus terminal

2020-03-29 16:57:45 IO resulting scope: {'title': 'Terminal - ./run.sh', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-29 16:57:45 IO resulting scope: {'title': 'Terminal - ./run.sh', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-29 16:57:45 IO resulting scope: {'title': 'Terminal - ./run.sh', 'doc': '', 'filename': '', 'file_ext': ''}

Focus Pycharm

2020-03-29 16:57:48 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/misc/standard.talon - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-29 16:57:48 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/misc/standard.talon - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-29 16:57:48 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/misc/standard.talon - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-29 16:57:48 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/misc/standard.talon - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-29 16:57:48 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/misc/standard.talon - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

Switch to different file (not standard.talon)

2020-03-29 16:57:55 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/misc/standard.talon - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

Switch to different file (not standard.talon)

2020-03-29 16:58:01 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/misc/standard.talon - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

lunixbochs commented 4 years ago

Can you show alongside:

ui.register('win_title', print)
ui.register('win_focus', print)
hbk619 commented 4 years ago

Added title change and focus change to show the different debug lines. It looks like on title change doesn't actually update the title, just triggers the event

2020-03-30 14:33:56 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/code/test.py - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-30 14:33:56 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/code/test.py - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-30 14:33:56 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/code/test.py - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-30 14:33:56 IO focus change Window(app=App(pid=11002, "jetbrains-pycharm-ce"), title=".talon [~/.talon] - .../user/knausj_talon/code/test.py - PyCharm")

2020-03-30 14:33:56 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/code/test.py - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-30 14:33:56 IO title change Window(app=App(pid=11002, "jetbrains-pycharm-ce"), title=".talon [~/.talon] - .../user/knausj_talon/code/test.py - PyCharm")

2020-03-30 14:33:57 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/code/test.py - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-30 14:33:57 IO title change Window(app=App(pid=11002, "jetbrains-pycharm-ce"), title=".talon [~/.talon] - .../user/knausj_talon/code/test.py - PyCharm")

2020-03-30 14:34:05 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/code/test.py - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-30 14:34:05 IO title change Window(app=App(pid=11002, "jetbrains-pycharm-ce"), title=".talon [~/.talon] - .../user/knausj_talon/misc/formatters.talon - PyCharm")

2020-03-30 14:34:08 IO resulting scope: {'title': '.talon [~/.talon] - .../user/knausj_talon/code/test.py - PyCharm', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-30 14:34:08 IO title change Window(app=App(pid=11002, "jetbrains-pycharm-ce"), title=".talon [~/.talon] - .../user/knausj_talon/text/generic_editor.talon - PyCharm")

2020-03-30 14:34:10 IO resulting scope: {'title': 'Terminal - ./run.sh', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-30 14:34:10 IO resulting scope: {'title': 'Terminal - ./run.sh', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-30 14:34:10 IO resulting scope: {'title': 'Terminal - ./run.sh', 'doc': '', 'filename': '', 'file_ext': ''}

2020-03-30 14:34:10 IO focus change Window(app=App(pid=10611, "Xfce4-terminal"), title="Terminal - ./run.sh")

fidgetingbits commented 4 years ago

I'm running into this as well on Arch Linux running i3 window manager, and termite. When I open a python or talon file with vim inside the terminal I don't see scope updates corresponding to the new window title, but I see the ui.register('win_title', print) callback fire. Focus changes cause the scope change to trigger.

lunixbochs commented 4 years ago

fixed in 1274