hyprland-community / pyprland

Scratchpads & many goodies for Hyprland [maintainer=@fdev31]
MIT License
345 stars 15 forks source link

[FEAT] [Scratchpads] Fully unmanaged scratchpads (eg: no command given) #127

Open fdev31 opened 1 month ago

fdev31 commented 1 month ago

Check #118 for the details.

Proposition:

fdev31 commented 1 month ago

@kuba-gaj can you provide some feedback testing the latest git version ?

If you also want less automatic changes on the style you can may try preserve_aspect=true.

fdev31 commented 1 month ago

Note: match_by="class" will be forced, for performance reasons there is no other matching type when no command is provided.

punk-dev-robot commented 1 month ago

thank you for the update,

I started testing it with one scratchpad like this:

[scratchpads.onepass]
animation = "fromBottom"
class = "1Password"
preserve_aspect = true

And I start the app myself with some initial rules:

exec-once=sleep 1 && 1password
windowrulev2 = float, class:^(1Password)$
windowrulev2 = pin, class:^(1Password)$
windowrulev2 = focusonactivate 1, class:^(1Password)$

It seems to kind of work.

I think preferably I would like to be able to control if the scratchpad starts visible or not and not have an extra call to toggle that is currently required.

It also looks like preserve_aspect isn't really working at the moment.

punk-dev-robot commented 1 month ago

It just occurred to me that maybe I could script running toggle after starting the app:

punk-dev-robot commented 1 month ago

Ok so there is another small issue.

Steps:

Jul 20 13:07:26 arch pypr[8184]:               scratchpads - run_toggle('onepass',) // command.py:202
Jul 20 13:07:26 arch pypr[8184]:               scratchpads - visibility_check: ('', '') == ('2', 'DP-3') // __init__.py:456
Jul 20 13:07:26 arch pypr[8184]:               scratchpads - onepass visibility: False and False // __init__.py:482
Jul 20 13:07:26 arch pypr[8184]:               scratchpads - Showing onepass // __init__.py:559
Jul 20 13:07:26 arch pypr[8184]:               scratchpads - clients // ipc.py:101
Jul 20 13:07:26 arch pypr[8184]:               scratchpads - dispatch movetoworkspacesilent special:scratch_onepass,address:0x606241923de0 // ipc.py:144
Jul 20 13:07:26 arch pypr[8184]:                  pyprland - event_activewindowv2('606241829d20',) // command.py:202
Jul 20 13:07:26 arch pypr[8184]:                  pyprland - active_window = 0x606241829d20 // pyprland.py:76
Jul 20 13:07:26 arch pypr[8184]:               scratchpads - monitors // ipc.py:101
Jul 20 13:07:26 arch pypr[8184]:               scratchpads - clients (CACHE HIT) // ipc.py:98
Jul 20 13:07:26 arch pypr[8184]:               scratchpads - dispatch ['moveworkspacetomonitor special:scratch_onepass DP-3', 'movetoworkspacesilent 2,address:0x606241923de0', 'alterzorder top,address:0x606241923de0'] // ipc.py:144
Jul 20 13:07:26 arch pypr[8184]:                  pyprland - event_activewindowv2('606241923de0',) // command.py:202
Jul 20 13:07:26 arch pypr[8184]:                  pyprland - active_window = 0x606241923de0 // pyprland.py:76
Jul 20 13:07:26 arch pypr[8184]:               scratchpads - dispatch ['movewindowpixel exact 2160 780,address:0x606241923de0'] // ipc.py:144
Jul 20 13:07:26 arch pypr[8184]:               scratchpads - dispatch focuswindow address:0x606241923de0 // ipc.py:144
Jul 20 13:07:26 arch pypr[8184]:                  pyprland - event_activewindowv2('606241923de0',) // command.py:202
Jul 20 13:07:26 arch pypr[8184]:                  pyprland - active_window = 0x606241923de0 // pyprland.py:76
Jul 20 13:07:26 arch pypr[8184]:               scratchpads - event_activewindowv2('606241829d20',) // command.py:202
Jul 20 13:07:26 arch pypr[8184]:               scratchpads - event_activewindowv2('606241923de0',) // command.py:202
Jul 20 13:07:26 arch pypr[8184]:               scratchpads - event_activewindowv2('606241923de0',) // command.py:202
Jul 20 13:07:29 arch pypr[8184]:               scratchpads - run_toggle('onepass',) // command.py:202
Jul 20 13:07:29 arch pypr[8184]:               scratchpads - visibility_check: ('2', 'DP-3') == ('2', 'DP-3') // __init__.py:456
Jul 20 13:07:29 arch pypr[8184]:               scratchpads - onepass visibility: True and True // __init__.py:482
Jul 20 13:07:29 arch pypr[8184]:               scratchpads - clients // ipc.py:101
Jul 20 13:07:29 arch pypr[8184]:               scratchpads - Hiding onepass // __init__.py:769
Jul 20 13:07:29 arch pypr[8184]:               scratchpads - dispatch ['movewindowpixel 0 660,address:0x606241923de0'] // ipc.py:144
Jul 20 13:07:29 arch pypr[8184]:               scratchpads - dispatch pin address:0x606241923de0 // ipc.py:144
Jul 20 13:07:29 arch pypr[8184]:               scratchpads - dispatch movetoworkspacesilent special:scratch_onepass,address:0x606241923de0 // ipc.py:144
Jul 20 13:07:29 arch pypr[8184]:                  pyprland - event_activewindowv2('606241829d20',) // command.py:202
Jul 20 13:07:29 arch pypr[8184]:                  pyprland - active_window = 0x606241829d20 // pyprland.py:76
Jul 20 13:07:29 arch pypr[8184]:                      pypr - This could be a bug in Pyprland, if you think so, report on https://github.com/fdev31/pyprland/issues // command.py:210
punk-dev-robot commented 1 month ago

Hmm, I think I got rid of above error by starting onepass after pyprland, or it's random atm :)

Now I toggled onepass a couple of times and killed the process.

When I run toggle I see error message (I would like not to as this is dummy mode without any tracking). What is even worse other scratchpad also stopped working:

Jul 20 13:36:18 arch pypr[8308]:               scratchpads - run_toggle('onepass',) // command.py:202
Jul 20 13:36:18 arch pypr[8308]:               scratchpads - visibility_check: ('2', 'DP-3') == ('2', 'DP-3') // __init__.py:456
Jul 20 13:36:18 arch pypr[8308]:               scratchpads - onepass visibility: True and True // __init__.py:482
Jul 20 13:36:18 arch pypr[8308]:               scratchpads - clients // ipc.py:101
Jul 20 13:36:18 arch pypr[8308]: ERROR:scratch:The client window 0x5574909ff800 vanished
Jul 20 13:36:18 arch pypr[8308]:                      pypr - scratchpads::run_toggle(('onepass',)) failed: // command.py:213
Jul 20 13:36:18 arch pypr[8308]: Traceback (most recent call last):
Jul 20 13:36:18 arch pypr[8308]:   File "/usr/lib/python3.12/site-packages/pyprland/command.py", line 208, in _run_plugin_handler
Jul 20 13:36:18 arch pypr[8308]:     await getattr(plugin, full_name)(*params)
Jul 20 13:36:18 arch pypr[8308]:   File "/usr/lib/python3.12/site-packages/pyprland/plugins/scratchpads/__init__.py", line 487, in run_toggle
Jul 20 13:36:18 arch pypr[8308]:     await asyncio.gather(*(asyncio.create_task(t()) for t in tasks))
Jul 20 13:36:18 arch pypr[8308]:   File "/usr/lib/python3.12/site-packages/pyprland/plugins/scratchpads/__init__.py", line 755, in run_hide
Jul 20 13:36:18 arch pypr[8308]:     await scratch.update_client_info(clients=clients)
Jul 20 13:36:18 arch pypr[8308]:   File "/usr/lib/python3.12/site-packages/pyprland/plugins/scratchpads/objects.py", line 179, in update_client_info
Jul 20 13:36:18 arch pypr[8308]:     raise KeyError(msg)
Jul 20 13:36:18 arch pypr[8308]: KeyError: 'Client window 0x5574909ff800 not found'
Jul 20 13:36:18 arch pypr[8308]:                       ipc - notify 0 5000 rgb(ff1010)  Pypr error scratchpads::run_toggle: 'Client window 0x5574909ff800 not found' // ipc.py:144
Jul 20 13:36:33 arch pypr[10276]: [07/20/24, 13:36:33:387] info: [DND_V2] (T033J3T2Y) Checking for changes in DND status for the following members: U014H9J7CUD
Jul 20 13:36:33 arch pypr[10276]: [07/20/24, 13:36:33:388] info: [DND_V2] (T033J3T2Y) Will check for changes in DND status again in 5 minutes
Jul 20 13:36:39 arch pypr[8308]:                  pyprland - event_activewindowv2('55749097e450',) // command.py:202
Jul 20 13:36:39 arch pypr[8308]:                  pyprland - active_window = 0x55749097e450 // pyprland.py:76
Jul 20 13:36:39 arch pypr[8308]:               scratchpads - event_activewindowv2('55749097e450',) // command.py:202
Jul 20 13:38:40 arch pypr[8308]:               scratchpads - run_toggle('dropterm',) // command.py:202
Jul 20 13:38:40 arch pypr[8308]:               scratchpads - visibility_check: ('2', 'DP-3') == ('2', 'DP-3') // __init__.py:456
Jul 20 13:38:40 arch pypr[8308]:               scratchpads - dropterm visibility: False and False // __init__.py:482
Jul 20 13:38:40 arch pypr[8308]:               scratchpads - Showing dropterm // __init__.py:559
Jul 20 13:38:40 arch pypr[8308]:               scratchpads - keyword windowrule unset,^(term-drop)$ // ipc.py:144
Jul 20 13:38:40 arch pypr[8308]:               scratchpads - clients // ipc.py:101
Jul 20 13:38:40 arch pypr[8308]: ERROR:scratch:The client window 0x5574909ff800 vanished
Jul 20 13:38:40 arch pypr[8308]:                      pypr - scratchpads::run_toggle(('dropterm',)) failed: // command.py:213
Jul 20 13:38:40 arch pypr[8308]: Traceback (most recent call last):
Jul 20 13:38:40 arch pypr[8308]:   File "/usr/lib/python3.12/site-packages/pyprland/command.py", line 208, in _run_plugin_handler
Jul 20 13:38:40 arch pypr[8308]:     await getattr(plugin, full_name)(*params)
Jul 20 13:38:40 arch pypr[8308]:   File "/usr/lib/python3.12/site-packages/pyprland/plugins/scratchpads/__init__.py", line 487, in run_toggle
Jul 20 13:38:40 arch pypr[8308]:     await asyncio.gather(*(asyncio.create_task(t()) for t in tasks))
Jul 20 13:38:40 arch pypr[8308]:   File "/usr/lib/python3.12/site-packages/pyprland/plugins/scratchpads/__init__.py", line 573, in run_show
Jul 20 13:38:40 arch pypr[8308]:     await self.run_hide(e_uid, flavor=HideFlavors.TRIGGERED_BY_AUTOHIDE | HideFlavors.IGNORE_TILED)
Jul 20 13:38:40 arch pypr[8308]:   File "/usr/lib/python3.12/site-packages/pyprland/plugins/scratchpads/__init__.py", line 755, in run_hide
Jul 20 13:38:40 arch pypr[8308]:     await scratch.update_client_info(clients=clients)
Jul 20 13:38:40 arch pypr[8308]:   File "/usr/lib/python3.12/site-packages/pyprland/plugins/scratchpads/objects.py", line 179, in update_client_info
Jul 20 13:38:40 arch pypr[8308]:     raise KeyError(msg)
Jul 20 13:38:40 arch pypr[8308]: KeyError: 'Client window 0x5574909ff800 not found'
Jul 20 13:38:40 arch pypr[8308]:                       ipc - notify 0 5000 rgb(ff1010)  Pypr error scratchpads::run_toggle: 'Client window 0x5574909ff800 not found' // ipc.py:144
Jul 20 13:39:27 arch pypr[8308]:                  pyprland - event_activewindowv2('5574909bec30',) // command.py:202
Jul 20 13:39:27 arch pypr[8308]:                  pyprland - active_window = 0x5574909bec30 // pyprland.py:76

hyprctl

Window 557490ac5f10 -> tmux:
        mapped: 1
        hidden: 0
        at: 1600,-1296
        size: 1920,1296
        workspace: -93 (special:scratch_dropterm)

Then I started onepass again but pyprland is still in broken state (window not found)

fdev31 commented 1 month ago

In the first log, you stopped it exactly at the line which starts to explain the error, so I can't help without the details.

The relevant content (eg: class) has also been removed from your second log.