7 ms·
Show HN: Vim-Like Layer for Xorg and Wayland
- Ianvdl 6y agoAs someone who uses Vim daily, I quite like this idea. I would customise it to mimic the original Vim bindings a bit more closely where possible though, to e.g. keep Ctrl-D as page down. I'm not sure if this would be possible, but it would be fun to have customisable per-application bindings (based on the active window, probably) in addition to the set of global bindings. I can also think of minor cases where motions would be useful, like 3x alt-tab (i.e. 3gt) to switch to a specific application. I wonder at what point the depth of the mode-ness will become too much, if you were running this, for example, with a vi-mode bash readline.
- ceda_ei 6y ago> e.g. keep Ctrl-D as page down. I tried doing the same using xdotool by binding Ctrl+F<something> to PageDown but for some reason it didn't work for some reason and I didn't investigate enough.
- addcninblue 6y agoI believe a possible reason is that the OP used xkb, which if I'm not mistaken is lower level than xdotool (so xdotool would not suffice)
- ceda_ei 6y agoI am the OP. What I tried was something along these lines. e.g. to get w in normal mode to send Ctrl+right, I did the following. 1. Bind w to F14 in normal mode. 2. In i3 config, add `bindsym 0xffcb exec xdotool key ctrl+Right` If I simply ran the command (`xdotool key ctrl+Right`) in normal mode, it would work but it didn't work via a binding. This was infact the initial idea behind all this but after quite some testing xdotool turned out to be unreliable so I repurposed it as a shortcut layer.
- dlkmp 6y agoI've done a similar thing at the hardware level using a QMK layer. The main benefit for me is being able to use VIM movement keys in every text input. As I'm using a dual boot setup, it's also pretty handy to have the mapping directly embedded in the keyboard firmware.
- modalkb 6y agoCare to share please?
- Ianvdl 6y agoThanks for mentioning QMK [0], it's not something I've heard of before, and it seems like a huge step up from standard keyboard firmware. As far as I can tell only a small number of manufacturers officially support it, but at least one person seems to have made some progress getting a standard cooler master keyboard to run it [1]. [0] https://qmk.fm/ https://qmk.fm/ [1] https://github.com/qmk/qmk_firmware/tree/master/keyboards/bpiphany/unloved_bastard https://github.com/qmk/qmk_firmware/tree/master/keyboards/bp...
- secure 6y agoIt’s reasonably simple to port QMK (at least partially) to a new microcontroller. I have worked on Teensy 3.6 support for QMK, and plan to work on Teensy 4.x support as well.
- Ianvdl 6y agoIs any special hardware needed, or is it all software work?
- rfoo 6y agoIt's more like full-hardware-no-software work. Basically if you want to use this on your "standard" keyboards bought off the shelf, you have to either: 1. Open your keyboard, replace the keyboard controller with something that you can program via soldering etc. or 2. Pray your keyboard doesn't use a mask ROM to store its firmware, and it has a powerful enough MCU as keyboard controller, then figure out how to reflash it and port QMK to it blindly.
- seqizz 6y agoGood idea. This could be also useful for assigning custom functionality instead of vim (e.g. window management). Also one can switch backlights/keyboard colors depending of the keyboard mode for visual feedback.
- modalkb 6y agoI just had a crazy idea based on this- (it's not going to be useful as is, mostly novel and potentially good) You know how a desktop screen is fixed width and windows cannot be outside of the screen (at least in tiling), I want a single workspace for all windows, where they arrange non-ovrlappingly and screen would just be a view to a fixed point so I can scroll (quickly using hjkl) in 4 directions to look at other windows and even maybe select a group of windows and make them my current view. Much more dynamic than i3, my current wm.
- mgraczyk 6y agoSounds a bit like the infamous 10/GUI http://10gui.com/video/ http://10gui.com/video/
- ceda_ei 6y agoSomewhat related: https://github.com/SimulaVR/Simula https://github.com/SimulaVR/Simula. This is the same concept but with VR.
- vladvasiliu 6y agoI've never used AwesomeWM but from a brief reading, maybe it could do part of what you want: "maybe select a group of windows and make them my current view". From what I understand, windows don't belong to a workspace, but a workspace is a collection of windows having a certain tag. A given window may have multiple tags, so it can belong to multiple workspaces.
- lymitshn 6y agoLike this,paperwm? https://github.com/paperwm/PaperWM https://github.com/paperwm/PaperWM
- temptemptemp111 6y agoI bet you could make a DWM patch that does that... Do report back on how you get it done - thanks! :)
- secure 6y agoThe NEO keyboard layout (https://neo-layout.org/ https://neo-layout.org/) which I’m using for over a decade, has a similar concept of a number of additional layers. This is quite handy for having a bunch of special characters for programming readily available (hover over the layers on https://neo-layout.org/ https://neo-layout.org/ to see). For any other modal use-cases (e.g. resizing windows, changing music volume), I use i3’s modes: https://i3wm.org/docs/userguide.html#binding_modes https://i3wm.org/docs/userguide.html#binding_modes
- renke1 6y agoI am also using a custom keyboard layout (basically the movement layer from the NEO layout + left alt → left ctrl, right alt → left alt, caps lock → esc). Initially it was implemented as xmodmap, then as xkb layout and finally as C program using Interception Tools [0]. I had problems with both xmodmap and xkb where it wouldn't work in certain applications; Interception tools works everywhere (even in VMs and outside of X/Wayland). [0]: https://gitlab.com/interception/linux/tools/blob/master/README.md https://gitlab.com/interception/linux/tools/blob/master/READ...
- codethief 6y agoI came here to mention Interception Tools and you beat me to it! They really do work incredibly well! Currently I'm only using them to map my space bar to Ctrl upon holding using this[0] plugin. [0] https://gitlab.com/interception/linux/plugins/dual-function-keys https://gitlab.com/interception/linux/plugins/dual-function-...
- lejboua 6y agoThanks for this! I wanted to have a space that doubles as a layer key if kept pressed, and I wasn't having great success trying to do it with a custom program using the X bindings. This seems way simpler, while also more powerful.
- Fnoord 6y agoI'm looking for a way to have a key press becoming a repeated key press (for example 'a' producing 'a' every 150 ms). Is that possible with this software? I'm able to do it with AutoHotKey, but I'm unable to get it to work in Wine.
- renke1 6y agoI am pretty sure this is possible. The program called by Interception Tools can basically do anything (including being stateful), it just reads input events, rewrites it, ignores it, or raises entirely different input events etc. You could probably move your mouse with arrow keys if you wanted to.
- sieste 6y agoIn the fluxbox WM you could achieve something like this using keymodes http://fluxbox-wiki.org/Keymodes.html http://fluxbox-wiki.org/Keymodes.html
- codethief 6y agoI've been thinking about doing something like this for quite a while. One question that's been bothering me is: How will I know what mode I'm in? Can I somehow change the cursor system-wide? Can I add some sort of notification to my i3bar? EDIT: I just noticed that the article mentions this as a "bonus" at the end. Does this work reliably with i3status-rust? In case of i3bar at least there'd always be a delay coming from the low refresh rate of (in my case) 5s.
- ceda_ei 6y agoIn my case, the interval is set to 0.5 which has a slight delay but enough for me to not mind. I usually have a mental idea of what mode I am in at all times. > Can I somehow change the cursor system-wide? Check the arch wiki article on Cursor themes[0]. Generally,, DEs have nice support for switching cursor themes after startup. In either case, you would need to modify `xkb_swapper.sh` to set a cursor theme whenever the mode is changed. [0]: https://wiki.archlinux.org/index.php/Cursor_themes https://wiki.archlinux.org/index.php/Cursor_themes
- codethief 6y agoOh cool, I hadn't noticed that you were actually around here on HN! Thanks so much responding! > In my case, the interval is set to 0.5 I noticed that more frequent updates of the status bar do eat away at the battery, though. :\
- discreteevent 6y agoI wrote a keyboard hook in C for Windows (I was using AHK but it was unreliable). Initially it was modal but I found over time that I would get caught out. So now it's not modal. I hold down capslock and then use ijkl to navigate etc. The only thing left that is modal is spacebar for select/visual mode but I still a have to hold down capslock for that (e.g. capslock down, space bar, ijkl to select text, capslock up). Also I was using hjkl but switched to ijkl to match the arrow keys. I don't use vim enough anymore to justify hjkl. Holding down capslock turns out to not be a problem in practice. The main benefit of vim style navigation for me is not leaving the home row.
- ggm 6y agoSome concrete examples of using it? Did I miss the demo showing some good exemplary behaviour driven by this?
- geocar 6y agoHave you considered just using a (sticky) compose key and setting macros for some weird characters? That way you wouldn't have to run scripts to change modes.
- rlkf 6y agoI wonder if, instead of having two different layouts and changing between them, an alternative would be to put all the navigation keys at fifth level and above, and then hijack the Kanji modifier to switch to them, or maybe pretend you're a Far East keyboard and use Eisu_toggle.
- kohlerm 6y agoGet a keyboard with layer support, https://docs.qmk.fm/ https://docs.qmk.fm/. No need for different modes ...
- npmisdown 6y agoI'm fan of heavy key mapping customization to boost productivity. The most productive remapping so far which I made is to globally remap (via xkb) Left Alt + HJKL to respective arrow keys. Works in all GUI applications which rely on arrow keys for navigation, plus standard Ctrl + Shift + Left Alt + H (Left Arrow) works to select previous word in text fields (e.g. in browser). Next one is to remap Left Ctrl to Left Shift and to press it with upper side of the palm just below pinky (not sure how this part of the hand is called correctly) instead of utilizing finger for that. Works best on mechanical keyboards without bevels. Also I find quite useful to remap keys 5-0 to Right Shift + Q (5), W (6), E (7), R (8), D (9), F (0). I find these keys are easier to reach and type without a mistake instead of using standard 5-0 keys which you should stretch your fingers to type. For example, to type "()" I use Left Ctrl (remapped to Shift) + Right Shift + D, F which is easier to type without fingers leaving home row.
- Fnoord 6y agoI use Hammerspoon and Karabiner Elements on macOS to rebind keys (including the examples you gave). There's some examples and repositories available for these applications. On Windows, I use AutoHotKey, though mainly for gaming (be aware it can get you banned on some games though; investigate this beforehand). On Linux, I have a bit more difficulty with all of this because: 1) There's no standard application or configuration or even desktop. As of now I mainly use Gnome, but my preference would be to use more lightweight WM/DE on some of my devices. 2) I sometimes use a Linux desktop in a VM, from macOS.
- Timpy 6y agoDoes this get confusing when you're actually using Vim? Do you ever use Keyboard Normal Mode when you're in Vim?
- ceda_ei 6y agoNo, it doesn't. I use keyboard normal mode sometimes for things other than navigation, like seeking audio, etc
- fock 6y agosadly wayland means only sway. I've done some remapping as well, but don't know how to make Gnome in wayland mode (which is nice on a cramped notebook and someone has to test wayland...) read anything from a user-specified directory, so I have to edit stuff in /usr every update anew...
- jolmg 6y agoThey're using sway/i3. I don't understand why they're doing it like that when sway/i3 already has support for modes. They could have just done something like this in the sway/i3 config: mode "normal" { bindsym i mode "default" bindsym q kill bindsym y exec volchange -5 bindsym u exec volchange +5 bindsym o exec brightness -200 bindsym p exec brightness +200 bindsym w exec mpc prev bindsym e exec mpc toggle bindsym r exec mpc next ... } bindsym $mod+c mode "normal" EDIT: I've realized their method has the benefit of working with other window managers that don't support modes or on-the-fly reconfiguration.