donniebreve / touchcursor-linux

TouchCursor style keyboard remapping for Linux.
GNU General Public License v2.0
133 stars 28 forks source link

Layers and other enhancements... #73

Closed auouymous closed 2 months ago

auouymous commented 2 months ago

I decided to try keyd a while back and was in the process of switching because it was so much better. But then I realized it was using 18 times more memory than touchcursor-linux. So I wrote a couple patches to make touchcursor-linux better. ;)

They can be found at https://github.com/auouymous/touchcursor-linux/tree/layers or http://borg.qzx.com/files/touchcursor/. A cleaned up version of my conf file is also there, for reference only since it remaps the alphanumeric keys. The layers can easily be adapted because the patches changed behavior slightly so key codes are the remapped code, not original code.

The binary is 25% larger than without the patches, thanks to 1200-refactor-key-name-parsing.patch which significantly reduced the size, allowing the other patches to then double it. I have 76 layers and memory usage only doubled.

If you like the changes, I can start posting small PRs to add groups of patches.

1999shaswat commented 2 months ago

@auouymous I was testing out your code. First of all, thanks a lot for your contribution :)

My Setup

Working

Issue

auouymous commented 2 months ago

Answered at https://github.com/donniebreve/touchcursor-linux/issues/53#issuecomment-2179968476, but all of this is documented in the patched touchcursor.conf file, I recommend reading it or go to https://github.com/auouymous/touchcursor-linux/blob/layers/touchcursor.conf.

Can I do it automatically when a keyboard is connected?

I use KERNEL=="event*", ATTRS{name}=="Virtual TouchCursor Keyboard", SYMLINK="input/event-touchcursor-kbd" to create a symlink when the service starts. It might be possible to alter that using RUN+="..." instead of SYMLINK. The ATTRS{name} value can be replaced with keyboard name to run kill or pkill when connected. I'll play around with it.

Or I could write another patch that adds an action to reload the service, same thing HUP does. You could then bind that action to a key in a layer and press it on a working keyboard after connecting another.

auouymous commented 2 months ago

The following line in /etc/udev/rules.d/00-touchcursor.rules will reload touchcursor when a keyboard is connected. You will need to change the path to the touchcursor binary if not in /usr/sbin, and remove the --uid touchcursor if touchcursor runs as root. Duplicate that line for each keyboard that can be disconnected. And pkill is in the procps package if you are missing it.

KERNEL=="event*", ACTION=="add", ATTRS{name}=="Your Keyboard", RUN+="/usr/bin/pkill -HUP --uid touchcursor --full '^/usr/sbin/touchcursor$'"
donniebreve commented 2 months ago

If you like the changes, I can start posting small PRs to add groups of patches.

If you would like to work with and contribute to this project, please do so. Like any open source project, you should submit small and focused pull requests for review. I may not accept everything, in which case you may want to continue maintaining a fork.

As a suggestion for the future, it would be a good idea to discuss desired changes to a project with the maintainers before endeavoring to make those changes.

I decided to try [other project] a while back and was in the process of switching because it was so much better.

As you two have noticed, there are many other projects out there with many more features. One of my favorites is kmonad. I also use Karabiner Elements. If this project doesn't fit your needs, you're free to use the myriad of other projects out there. The goal of this project was to replicate the core functionality of Touch Cursor on Linux, and give me an excuse to learn some C.

I was testing out your code... ... go to https://github.com/fork...

This isn't the place to discuss or promote forks or other projects. Please keep all discussions here centered on the development, features, and issues pertaining to this project.

auouymous commented 2 months ago

I may not accept everything

That is why I grouped the patches by numbers in the patches.tar.gz file. I assume the first groups of patches will be merged since they fix issues, and I would have started submitting sooner but didn't have time.

Several of the early patches fix issues in queue.c and then 1403 removes the queue files. But I included them knowing the other patches might not be accepted.

The 14xx group are the questionable patches that may or may not get merged. You've mentioned wanting layers, and wanting separate services for multiple keyboards. This patch set demonstrates why a single service should handle all devices, due to output modifiers. And being able to see the entire patch set might make it easier for you to understand some changes in earlier patches.

in which case you may want to continue maintaining a fork.

I'm not interested in maintaining a fork, because chosing a name is too much work, and not enough time in the day. Anything not accepted will only be maintained locally.

As a suggestion for the future, it would be a good idea to discuss desired changes to a project with the maintainers before endeavoring to make those changes.

I had an itch to scratch and took care of it, like most open source. These patches were written and then rewritten multiple times over time as I refined them as a whole. And now we can work together to potentially refine them more. I also have notes for each patch that would need discussion.

As you two have noticed, there are many other projects out there with many more features.

Not any more, touchcursor with my patches is everything I want, and a little I don't want but others might. There are a couple more small features I may or may not implement in the future.

This isn't the place to discuss or promote forks or other projects. Please keep all discussions here centered on the development, features, and issues pertaining to this project.

I made some changes to this project and am giving them back, nothing is being promoted.

1999shaswat commented 2 months ago

The following line in /etc/udev/rules.d/00-touchcursor.rules will reload touchcursor when a keyboard is connected. You will need to change the path to the touchcursor binary if not in /usr/sbin, and remove the --uid touchcursor if touchcursor runs as root. Duplicate that line for each keyboard that can be disconnected. And pkill is in the procps package if you are missing it.

KERNEL=="event*", ACTION=="add", ATTRS{name}=="Your Keyboard", RUN+="/usr/bin/pkill -HUP --uid touchcursor --full '^/usr/sbin/touchcursor$'"

It worked for me. Thanks a lot!!

Modifications: KERNEL=="event*", ACTION=="add", ATTRS{name}=="Your Keyboard Name", RUN+="/usr/bin/pkill -HUP --uid your_username --full '^/usr/bin/touchcursor$'"

"Your Keyboard Name" should be the keyboard name used in touchcursor config file To find path of touchcursor binary, use command which touchcursor To find path of pkill binary, use command which pkill To find username, use command whoami