ILikeAI / AlwaysReddy

AlwaysReddy is a LLM voice assistant that is always just a hotkey away.
MIT License
621 stars 61 forks source link

Switch to pynput module #13

Closed ArjenR closed 4 months ago

ArjenR commented 5 months ago

This PR switches to the pynput module to handle hotkeys. This will enable to run AlwaysReddy as a non-root user. For issue https://github.com/ILikeAI/AlwaysReddy/issues/11

Limitations:

And it also adds my venv to .gitignore, which I thought I kept outside of the feature branch... It is a good practice to use python venv's for your (dev) environments anyway.

ILikeAI commented 5 months ago

Thanks for the PR this looks great! I am hoping to get linux set up so i can test it locally asap.

Im a fan of the current Ctrl+Shift+Space hotkey so i may not use this new library as the default hotkey handler but instead try to set it up in a way so that Linux users can use that library instead. Unfortunately I have a lot on my plate for the next few days so I will see how I go making these modifications, Ill try to get it setup asap.

Yep I was thinking about Venvs last night, good call

ILikeAI commented 5 months ago

Just letting you know that I have been playing with your code changes on my own branch. Check out the WIP branch to have a look. I've set up a separate file as a keyboard handler that can identify which operating system a user is on and will select a different hotkey handler depending. Let me know what you think of this. Also, sorry I'm a bit of a noob to GitHub, so I'm not sure if this is the proper protocol. If I want to modify someone else's pull request, let me know if I've done anything wrong here. Here are some thoughts though:

It appears that some Linux users will need to run as root anyway, depending on their display protocol. This makes me wonder if maybe it's best to have all users just use their default keyboard library with root permissions so that then we could at least have the same keyboard hotkeys across the different platforms, meaning we can still use the default Control+Shift+Space. I am a bit of a fan of that hotkey, haha. I'm not sure though, let me know what you think of this. It's possible that there's somewhere in the middle where people can use the version without root privileges if they prefer, but they'll have to deal with different hotkeys. But by default, you need to give it root privileges and deal with the standard hotkeys... Or maybe im just way too attached to the current hotkey setup becuase im used to it lol

Let me know what you think. Either way I doubt the current content of WIP will be the final verison

ILikeAI commented 5 months ago

Side note: looks like the clipboard functionality does not work properly for me on linux, did you get that too?

An error occurred while getting completion: 
    Pyperclip could not find a copy/paste mechanism for your system.
    For more information, please visit https://pyperclip.readthedocs.io/en/latest/index.html#not-implemented-error 
ILikeAI commented 4 months ago

Pynput is now integrated