-
-
Notifications
You must be signed in to change notification settings - Fork 847
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
Macros: multi-stage output events #2711
Comments
I'm pleased to report Karabiner can totally do this! Finally occurred to me to just try putting multiple So I've made a bunch. Typing out simple strings is just the start of it. I've made word selection and paragraph selection macros—which use sequences of modifier keys to do their work—and wrapping macros which throw the clipboard into the mix with Command + X and V. First: word selection. It works just as I suggested above. Use the arrow keys, Option and Shift, in sequence:
Wrapping is a bit more involved. For instance, here's 'quote' "wrapping":
Two macros: one for 'single' and one for "double" quotes. Letting Now, there's one big flaw with these wrap macros: they use the clipboard. Using the clipboard to store the text isn't the cleanest way, I know. Use these macros and your existing clipboard contents are destroyed. (I use a clipboard history utility so this doesn't trip me up, but it's definitely suboptimal.) If there's a more elegant way, I'd love to know! But these macros do really work. Everywhere! These all work in every app across the Mac thanks to Karabiner; much more reliably than Cocoa Keybindings which are sleek but obscure and are often just not supported at all in whatever app you're using. No such problem for Karabiner! |
Here's an example of speeding up dead keys for diacritical marks. I want to type àèìòù as easily as holding down Shift to type AEIOU. Nò pròblèmò!
Again, a separate macro is necessary for à and À, because Shift gets in the way of the dead key sequence Karabiner's robotically pressing really quickly for me. Previously, every stràc that came up in Gaelic, I'd have to twiddle around with Option + ` then press the key. That made À a four key sequence. Much better when the robot's got your back! I guess this issue is now closed. I'll mark it closed in a bit. I can imagine improvements to support macros: especially storing the pasteboard. But now I can see how Karabiner approaches this problem, I recognise I'm imagining un-Karabiner things! |
About clipboard problem: You can save the current conent in main clipboard in a different clipboard, and move them back after seding |
Oh, that's helpful! Thanks. Here it is in action:
My only complaint is it still messes up clipboard history. Ideally, I'd like to run these macros without messing up my clipboard or its history, given I can see that as a menu in Jumpcut. I use my clipboard history a lot and would love to keep it clean while using these macros. Any way to bypass the general clipboard entirely, and send / restore the selection straight to / from the ruler pasteboard instead? I keep dreaming of Karabiner manipulating the clipboard itself, rather than just the keyboard! |
Have you tried
If you want to use Your this
sends the output to Karabiner which will discard them. You probably forgot to add
|
Control + K seems to use the main system clipboard here on M1 Big Sur. I tested with this:
Running that macro on a text selection successfully wraps it with [brackets] but the text winds up in my clipboard history just as before. Strange. As for your suggestion about my code: I tested my macros they do work. Try it yourself: these code samples are complete JSONs you can throw straight at Karabiner. You may have a fair point I'm just not understanding, however ;) |
Okay, I think I get what you mean now! It's about saving the clipboard before I meddle with it. Here's my test of your suggested code:
Problem remains: run this and the selected text still winds up in Jumpcut's clipboard history. Maybe I should go investigate what clipboards Jumpcut is tracking… Playing with |
Oh boy… Experimenting with Control + K and Control + Y, I discover their behaviour is app specific. I was using BBEdit for my tests, and BBEdit syncs their clipboard with the general system pasteboard. TextEdit however keeps them apart. Safari considers them separate too. Scrivener is the same way. Oh, and all these apps (besides BBEdit) have separate pasteboards! So, soon enough I found myself with several simultaneous separate hidden pasteboards! Right now, there's different text pasting on Control Y in all 4! So yeah, it's complicated. But better than nothing. I'll edit my macros to all use Control + K and Y. Most of my writing is not in BBEdit so should stay out of Jumpcut this way. Hopefully. Let's see! Aye, my macros seem to behave nicely now, outside of BBEdit. I've fired Bare Bones a support email to see if this is intended behaviour. |
The problem is with getting the currently selected text. I don't know any method for it except using clipboard. |
Yeah, me neither. Thanks for all your help though, it's been very useful indeed! Especially the one about Control Y and K. I vaguely remembered there was "another copy/paste on the Mac somewhere" but I had no idea how to go find it. Control Y and K seems to be working nicely, outside of BBEdit. Maybe that's just a BBEdit bug. I'll know when Bare Bones get back to me. I also just added |
Bare Bones got back to me real quick. BBEdit doesn't maintain a separate kill buffer, and that can't be reconfigured. Apparently it's just the way their Emacs keybinding emulation works. Anyway, all other apps I'm trying today are working fine with Control Y and K, so I reckon I'll just keep it this way. Only BBEdit leaves unwanted clipboard history, and my macros still work with it otherwise. I've very almost achieved what I wanted. Phew! My thanks to Muhammed and Karabiner! |
To not make this a little easier, you could ask developer of your clipboard manager to add a cli or menu option to enable/disable/ignore clipboard watching. Then, you will be able to toggle it using shell script, or AppleScript. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Thanks for reminding me to close this, bot! I've been doing plenty with Karabiner macros, including single keystroke text selection and clipboard manipulation. For those interested, I've written loads about it here: https://deskthority.net/viewtopic.php?p=494473#p494473 Macros are awesome! |
VSCode has this functionality. and it does not mess with the clipboard history. i have no idea how they achieved this. it also works with all wrapping type characters: ( , { , [ , " , ' |
This is probably a feature request. I have searched Karabiner's documentation and other people's rules for macros but can't find anything about it.
What I want to achieve with macros is stuff like this, on a single trigger keystroke:
In a nutshell: "from": events triggering whole chains of "to": events.
I do lots of macro stuff like this with Soarer's Converter and it can be tremendously useful. I'd love to be able to do it across all my keyboards, including my MacBook Air's own. Are sequences simply beyond Karabiner's scope?
(Karabiner really is a lot of fun, once you get into writing your own complex rules. Brilliant stuff! My biggest thanks to Tekezo and everyone who works on this project. Love it to bits!)
The text was updated successfully, but these errors were encountered: