jtroo / kanata

Improve keyboard comfort and usability with advanced customization
GNU Lesser General Public License v3.0
2.16k stars 111 forks source link

Nerf dynamic macros (how I messed up by running one that has been recording for days) #595

Closed isti115 closed 10 months ago

isti115 commented 11 months ago

Let me preface this by saying that I am aware of the fact that this one 100% user error on my part, and I don't mean to blame anyone else for it, the reason why I'm creating this issue is that I'd like to find some way to prevent other people from making the same mistake in the future.

So, I had a massive oopsie today. I was experimenting with dynamic macros a while back, and they remained in my mapping afterwards. Having forgotten about them I accidentally pressed the recording combination a few days ago, which I still did not realize until today, when I accidentally pressed the combination for playback and my system turned into complete chaos as it started repeating every single keystroke I made in the last few days.

I was in my editor (neovim), in which it started obliterating the contents of my files, and even opened my git plugin (lazygit, which is again, fully operable from the keyboard only, so who knows what it did in the repo... [Edit: According to the reflog it seems to have amended a commit.]) but I managed to force quit from there. Afterwards it started to open terminals and typing commands into them, which made me panic even more, but I tried to fight it by repeatedly pressing Ctrl+C to cancel anything that might be ran and / or break the commands into meaningless parts.

All this happened in a matter of a few seconds.

After a snippet of text appeared that I recognized, having typed it a few days ago, I realized what was happening, and while frantically hammering Ctrl+C on my keyboard with one hand, I ssh-d into my PC from my phone and issued sudo pkill kanata, which finally put an end to the ensuing chaos. I closed the remaning terminals, and seen that in one of them a file copy / move operation (through lf, so I couldn't even check the source / destination... 😐) was in progress, but so far I have yet to discover any serious damage, so let's hope that no such thing happened!

In my brief post-mortem assessment I concluded that I probably should've reached for the power switch on the back of my PC right away, but I was so confused, that this solution has not occurred to me at the time. Another rational idea in such a situation would probably have been unplugging my keyboard (easier said than done, as it has a fixed wire on my end, and reaching the USB ports on the back of my PC would have been quite a stretch), which oddly enough wouldn't even have helped, as kanata doesn't stop when the bound input device is removed (which again, is not the fault of the software, this behavior makes perfect sense under normal operation). When in my frustration I decided to look for issues related to this feature, I found that it was inspired by QMK, where in case of such an accident the removal of the device would indeed help.

Anyway, as to things that could be done in my opinion:

ps. A strange thing I started to think about after the incident is that it never switched focus around my monitors, something that I otherwise do quite often. Could this have been due to the fact that I have home row mods, which somehow didn't activate during the playback? 🤔

jtroo commented 11 months ago

Thanks for opening the ticket! While unfortunate, reading this was quite amusing.

The doc update would be relatively simple. And perhaps the doc update should also include another reference to the kill kanata key combo which is lctl+spc+esc, which now that I'm looking for it, seems to have been removed from the docs at some point (probably by me), but should still work.

A limit to the length of the macro all sounds fairly feasible, and it should be easy enough to add a configuration for it in case a user wants more (or less).

jtroo commented 11 months ago

Another thought, maybe a log message showing lctl+spc+esc kill chord should be printed in the startup logs too, just to help people be aware of it.

isti115 commented 11 months ago

Thanks for the quick reply, I'm glad that at least I was able to provide some sort of weird entertainment through this, my coping mechanism currently is also to be amused by the absurdity of the situation. 😀

Even though I have since removed everything macro related from my config, I still gave the mentioned lctl+spc+esc combo a try, and it doesn't seem to work for me. :raised_eyebrow: Edit: It does indeed work, the issue was that I was trying to use the mapped positions of those keys, not the source / original one.

I know that this is very specific to my situation, but with this behavior (which makes sense, since it works, no matter what layer you're on) I couldn't even have utilized this escape hatch, as I'm using two numpads as a makeshift cheap "split ortholinear" keyboard, none of which originally have any of the required (control, space and escape) keys. :upside_down_face: Maybe making the panic sequence configurable is a good idea? I could try my hands at a PR for that. Or adding an exit action could also be helpful as an alternative to enabling commands and mapping a key to a command to kill kanata.