Giter VIP home page Giter VIP logo

dvorak's Introduction

Dvorak <> Qwerty - Keyboard remapping for Linux when pressing CTRL or ALT

Since I type with the "Dvorak" keyboard layout, the shortcuts such as ctrl-c, ctrl-x, or ctrl-v are not comfortable anymore for the left hand. And even one of them require two hands to press.

Furthermore, applications such as Intellij have their shortcuts, which I'm used to. So for these shortcuts I prefer "Querty". Since there is no way to configure this, it is necessary to intercept the keys and remap the keys from "Dvorak" to "Querty" when pressing CTRL, ALT, WIN or any of those combinations.

With X.org I was relying on the wonderful project from Kenton Varda. And then came Wayland.

Keyboard remapping with dvorak that works reliably with Wayland - make ctrl-c ctrl-c again

XGrabKey() works partially with some application but not with others (e.g., gedit is not working). Since XGrabKey() is an X.org function with some support in Wayland, I was looking for a more stable solution. After a quick look to this repo, I saw that Kenton added a systemtap script to implement the mapping. It scared me a bit to follow that path, so I implemented an other solution based on /dev/uinput. The idea is to read /dev/input, grab keys with EVIOCGRAB, create a virtual device that can emit the keys and pass the keys from /dev/input to /dev/uinput. If CTRL/ALT/WIN is pressed it will map the keys back to "Qwerty".

Kenton Varda reported that this project also works with Chrome OS if started as root.

Problems

The mapping does not work with Eclipse. Regular typing uses Dvorak, while the shortcuts are using Qwerty (I have not figured out why). This results in a situation where a Qwerty key gets remapped according to the Dvorak mapping.

Installation

  • create binary with make
  • install it with sudo make install

This will copy 3 files: dvorak, 80-dvorak.rules, and [email protected]

The file is triggered on the udev rule and call dvorak systemd service with the device that was attached. The rule contains the search term "keyb", that will match case insensitive the device name. Only a device with name that contains the substring "keyb" will be considered. To prevent an endless loop, the newly created virtual device is excluded from mapping itself.

That way, dvorak will be called whenever an input device is attached.

From here, ensure that your first keyboard layout is set to Qwerty and your second layout is Dvorak.

Not a matching device: [xyz]

If you see the above message in syslog or journalctl, it means that your keyboard device name does not have the string "keyb" (case insensitive) in it. For example, Not a matching device: [Logitech K360]. In order to make it work with your device, in [email protected], you can call be the executable with

ExecStart=/usr/bin/dvorak /dev/input/%i keyb k360

Related Links

I used the following sites for inspiration:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.