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

Scratchpads not working with keybind #10

Closed
JPDucky opened this issue Aug 8, 2023 · 7 comments
Closed

Scratchpads not working with keybind #10

JPDucky opened this issue Aug 8, 2023 · 7 comments
Labels
invalid This doesn't seem right

Comments

@JPDucky
Copy link

JPDucky commented Aug 8, 2023

I cannot get scratchpads to work. I have tried the same config as described in the wiki, but I cannot get a keybind to launch the scratchpad.

If I call pypr toggle term from the terminal, however, it does work- including removing the window when it loses focus.

in my hyprland.conf:

exec-once = pypr
# scratchpad
bind = ALT, code:51, exec, pypr toggle term
$dropterm = ^(kitty-dropterm)$
windowrule = float, $dropterm
windowrule = workspace special silent, $dropterm
windowrule = size 80% 70%, $dropterm

and in my pyprland.json:

{
  "pyprland": {
    "plugins": [
    "scratchpads",
    "monitors"
    ]
  },
  "scratchpads": {
    "term": {
      "command": "kitty --class kitty-dropterm"
    }
  },
  "monitors": {
    "placement": {
      "SB2": {
        "topOf": "eDP-1"
      }
    },
    "unknown": "wlrlui"
  }
}

running pypr --debug /tmp/pypr.log I get:

❯ pypr --debug /tmp/pypr.log
                      ipc - Logger initialized for ipc // common.py:70
                  startup - Logger initialized for startup // common.py:70
                     pypr - Logger initialized for pypr // common.py:70
              scratchpads - Logger initialized for scratchpads // common.py:70
                 monitors - Logger initialized for monitors // common.py:70
                      ipc - monitors // ipc.py:25
                     pypr - scratchpads.event_activewindowv2('5609d0214130\n',) // command.py:73
                     pypr - scratchpads.event_activewindowv2('5609d0214130\n',) // command.py:73
                     pypr - scratchpads.event_openwindow('5609d06194d0,special,kitty-dropterm,kitty\n',) // command.py:73
                      ipc - clients // ipc.py:25
              scratchpads - Hiding term // scratchpads.py:322
                      ipc - movetoworkspacesilent special:scratch_term,address:0x5609d06194d0 // ipc.py:53
                     pypr - scratchpads.event_activewindowv2('5609d0c2c8f0\n',) // command.py:73
                     pypr - scratchpads.event_activewindowv2('5609d0c2c8f0\n',) // command.py:73
                     pypr - scratchpads.event_activewindowv2('5609d0214130\n',) // command.py:73

but pressing my set keybind does not output anything to the log. I should note that I have also tried $mainMod + V to no avail.

I have tried both the pip package and build from source, both have the same behavior (1.4.0)

@fdev31
Copy link
Collaborator

fdev31 commented Aug 8, 2023

I guess you tested this keybind with another command to check it worked at all, if not, you can exec hyprctl notify -1 10000 "rgba(ffffffff)" "This is working".

If that works, in your keybind line, also log the output using --debug /tmp/pypr_command.log for instance and share it here please.

@fdev31
Copy link
Collaborator

fdev31 commented Aug 10, 2023

It's very likely a duplicate of #7, to debug those issues, in case the --debug file doesn't work because pypr can't initialize at all, then you might need to use a wrapper script such as:

#!/bin/sh
pypr toggle term --debug /tmp/pypr_toggle.log > /tmp/launch.log 2>&1

Feel free to re-open in case it's not a problem related to your python packages installation.

Try using your OS package manager for every package and get rid of pip installed ones, unless they run in a virtualenv.

@fdev31 fdev31 closed this as completed Aug 10, 2023
@JPDucky
Copy link
Author

JPDucky commented Aug 14, 2023

Swapped out my bind for launching the script you wrote above, and was getting command not found so I ran which on it and it was in my local bin. So I symlinked pypr to /usr/bin and tried again, and here is the output I'm getting:

cat launch.log
                      ipc - Logger initialized for ipc // common.py:70
                  startup - Logger initialized for startup // common.py:70
                     pypr - Logger initialized for pypr // common.py:70
                  startup - Unhandled exception: // command.py:241
Traceback (most recent call last):
  File "/home/palmerd/.local/lib/python3.11/site-packages/pyprland/command.py", line 233, in main
    asyncio.run(run_daemon() if len(sys.argv) <= 1 else run_client())
  File "/usr/lib64/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/palmerd/.local/lib/python3.11/site-packages/pyprland/command.py", line 211, in run_client
    _, writer = await asyncio.open_unix_connection(CONTROL)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/asyncio/streams.py", line 98, in open_unix_connection
    transport, _ = await loop.create_unix_connection(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/asyncio/unix_events.py", line 259, in create_unix_connection
    await self.sock_connect(sock, path)
  File "/usr/lib64/python3.11/asyncio/selector_events.py", line 634, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/lib64/python3.11/asyncio/selector_events.py", line 642, in _sock_connect
    sock.connect(address)
ConnectionRefusedError: [Errno 111] Connection refused

@JPDucky
Copy link
Author

JPDucky commented Aug 14, 2023

So I've reinstalled a couple times, and what has gotten me some progress is installing with sudo pip install pyprland then running pypr in a shell- which then lets me use my keybind to launch the script above. Problem is, when I run pypr with no command, it launches the the scratchpad, and the keybind will not launch unless I have already run pypr. I'm gonna do some more tweaking and I'll report back here.

@JPDucky
Copy link
Author

JPDucky commented Aug 14, 2023

Okay so switching my hyprland.conf back to the original config (see above), so long as I have pypr running somewhere else the keybind will work. Problem is, running pypr spawns that terminal at first launch.

Update: So I've got it working (I think)- I've put the following config into my hyprland.conf:

exec-once = ~/scripts/hypr/pyprl.sh
# scratchpad
bind = ALT, code:51, exec, pypr toggle term
$dropterm = ^(kitty-dropterm)$
windowrule = float, $dropterm
windowrule = workspace special silent, $dropterm
windowrule = size 80% 70%, $dropterm

and the contents of ~scripts/hypr/pyprl.sh are as follows:

#!/bin/bash

pypr &

I'm not sure why this works instead of just exec-once = pypr, but it does. You can go ahead and close this @fdev31

@fdev31
Copy link
Collaborator

fdev31 commented Aug 14, 2023

I'm pretty sure those are environmental issues, conflicting paths etc... manually installing things is a guarantee to get some problems at some point.

If you don't want pypr to start commands when it starts, but on the first "show" instead, you can use the "lazy=true" option in some scratchpads.
I may make this option the default in a near future.

@fdev31 fdev31 added the invalid This doesn't seem right label Feb 21, 2024
@fdev31
Copy link
Collaborator

fdev31 commented Feb 21, 2024

For my curiosity, was it fixed for you ?
Now there are alternatives:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants