-
Notifications
You must be signed in to change notification settings - Fork 433
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
X Inputs #33
Comments
That's an interesting idea, thank you. I have had some success in calling X
code directly with ctypes, so maybe the python-xlib dependency could be
removed.
Yes, eliminating the need for root would be awesome. I'll look into it when
I get home.
Thank you.
|
I originally started out using ctypes, but when I got to XEvent, which is a huge union, I said "forget this!" and switched to a lib. Here's what I have so far, though it's obviously incomplete: https://github.com/Xcelled/shorty/blob/master/x11.py |
By the way, here is some more code that may be helpful: https://github.com/PyUserInput/PyUserInput/blob/master/pykeyboard/x11.py |
Any update on this one? running root is little overkill for most cases, would be really nice to find a proper solution to avoid that |
I've been trying to use ctypes + the system's xlib.so, but couldn't make it work (calls either do nothing or segfault). The next options are trying raw sockets to connect to the X server (a lot more work, but doesn't depend on .so files) and, failing that, using python-xlib and sacrificing the "dependency-less" property of the library. Suggestions welcome. |
What do you think about trying to import From what I can see current solution is adding permissions to |
@lenisko That's not ideal, but I like the idea. I'll see what I can do. I'm not sure why your access control changes are not working. |
@boppreh any update on this one? |
The update is that this had become a complete nightmare, IIUC. Wayland is going to replace X and it has no global hotkey handler. |
@lenisko Tried again and still couldn't get pure X + ctypes working, haven't got around to adding Xlib yet. I'll also have to check how to add optional dependencies in pip, I don't want the people on Raspberry Pi needlessly installing xorg because of this. @xoviat That is indeed a problem. For the record, here's a thread about similar issues where they mention "Wayland doesn't allow clients to have an active grab" and "[Applications] won't be able to get events for key combos that are registered as global shortcuts in the compositor". For now, Xlib will help at least some of the cases. |
@xoviat I wouldn't expect instant switch on all distributions, for example I'm not using Wayland. @badtyprr what about For now library is useless on Unix systems I mean using I'll monitor your changes, cheers! |
Good news, xlib integration is being worked on: https://github.com/boppreh/keyboard/tree/xlib I'm following @lenisko's idea of importing xlib when it's available, or falling back to raw devices. If the import fails due to lack of sudo, the message will also reflect that using xlib is an option. Right now basic hooks are working, so if you have Feature roadmap:
I'll also give udev a try (#124), maybe we get multiple Linux backends. |
@boppreh will capturing from raw devices still work on Wayland? planning to build a mini service to capture hotkeys regardless of whether there is a display connected and trying to understand if this library is wayland-friendly; this is for an HTPC running Xorg but sooner or later wayland is coming |
@arigit The current behavior of capturing raw devices is not going to go away. I'm still thinking on how to let the user decide which backend to use, but at the moment you need to have python-xlib installed to have anything other than raw device capture. |
Will there be any update on this? There seems to be no actual xlib code pushed to the branch. |
I'd be willing to work on this (and or #124), what would I need to do? |
@izik1 : thank you for your interest. These functions need to be implemented in a submodule for it to be a "backend":
Once you have this basic functions in a submodule, the main module can tap into it as a backend and add all the hotkey/macro/recording stuff. You can look at the other OS backends to see how it's usually done, or look for "os_keyboard." invocations in the main module to see how its used. I realize this explanation is very bare bones, but I've started working again on this library so I'll do my best to support you on this. |
@boppreh welcome back!! |
It seems like for a rootless access on linux the following is enough:
|
@nartes, it's not a solution though, it's just a hack. But thanks for a temporary workaround nonetheless |
Absolutely. I already rely on X anyway to find windows location and record them. Telling my users to add themselves to groups, setting rules and permission. Is not a viable long-term solution, at best it's a patch while I'm working on full feature-parity with Windows. If it's still the case by the time I'm done with all other features, I'll simply have to drop the keyboard module and rewrite all of my hotkeys code. Which I would rather not have to do ^^" |
Would you be interested in an X-based global hotkey capture? I wrote (most of) one in an effort to make a global-hotkey-library before I found this project. It has a dependency on python-xlib, but that's preferable to having to run as root. Root mode could still be used as a fallback if the xlib package isn't available, still keeping the "zero dependency" guarantee.
Obviously, my code would need to be adapted to your architecture, but I don't think that should be too hard.
The text was updated successfully, but these errors were encountered: