How To Experiment With Your Keymap
Hi there! Today’s topic is about tweaking your keymap, conveniently. It’s a little trick I use when developing Jwno, and I hope it’s useful to you too.
If you have coincidentally read the documentation or the example config, you’ll see such a pattern to set up your root keymap:
(def root-keymap (:new-keymap (in jwno/context :key-manager)))
(:define-key root-keymap ...)
...
(:set-keymap (in jwno/context :key-manager) root-keymap)
These code usually lives in your config file, and gets evaluated only when Jwno starts afresh. But what if we wanted to experiment with some keys or commands? Do we just keep changing the config file and restart Jwno again and again?
Of course not! If something can be done in the config file, you can do it in the REPL too, while Jwno is still running! All we need is a reference to the root-keymap
. You can add these lines to your config file:
(import jwno/util)
(def repl-server
(or (:get-default-server (in jwno/context :repl-manager))
(:start-server (in jwno/context :repl-manager))))
(util/export-to-repl repl-server root-keymap)
And voila, we can manipulate root-keymap
in the REPL! Say we want to try out the :insert-frame
command:
Welcome to Jwno REPL!
[127.0.0.1:9999]:1: (:define-key root-keymap "Win + F I" [:insert-frame :after])
...
[127.0.0.1:9999]:2: (:define-key root-keymap "Win + F Shift + I" [:insert-frame :before])
...
[127.0.0.1:9999]:3: (:set-keymap (in jwno/context :key-manager) root-keymap)
The new keys will take effect immediately, no restart or editing to the config file needed. We can keep changing the keymap, then incorporate the new keys into the config file only after we’re satisfied with the result, or restart Jwno to revert to the old keymap if we messed up something.
Sidenode:
Some people may find it unusual, that Jwno does not provide a default kemap. It’s because I wanted Jwno to be your personal tool, which is uniquely tailored to your use cases and workflows. Given the ability to dynamically manipulate keymaps in the REPL, you can as well start Jwno with an empty keymap, and build it up from scratch, piece by piece. The point is, you should be able to play with it, and have fun in the process.
That said, I can understand that some users may want something which works out-of-box, and I’m considering a new feature to embed a user-specified config file directly into jwno.exe
. Stay tuned if you’re interested. Cheers! 🤘
Get Jwno
Jwno
A tiling window manager for Windows 10/11, built with Janet and ❤️.
Status | In development |
Category | Tool |
Author | Agent Kilo |
Tags | janet, tiling, uiautomation, window-manager, windows |
More posts
- Playing With WSLg Windows6 days ago
- How To Use Jwno With Your Ultrawide Monitors41 days ago
- Jwno 0.9.9 Released48 days ago
Leave a comment
Log in with itch.io to leave a comment.