DEV Community

Cover image for I Got Tired of the Way I Type Parentheses on a QWERTY Keyboard
zinnwan
zinnwan

Posted on

I Got Tired of the Way I Type Parentheses on a QWERTY Keyboard

I was used to AZERTY layout

I was forced to use AZERTY keyboards because, they are the default layout in my region. Recently I acquired a QWERTY keyboard. I’m getting used to it but, there are some keys that shouldn’t be placed the way they are. My first and major issue was the parentheses key. To type left parentheses you need to hold the SHIFT_KEY and press 9. I use left parentheses quite a lot, I got tired, and tried to change it.

Here’s how I changed my keymaps

I should mention that I’m on Fedora, this should work on all Linux machines (sorry Windows, and Mac users).

  • On your home directory, create a file and name it “.Xmodmap”.
  • Open the file in your text editor.
    • Here is the basic syntax:
    keycode 'Number' = 'Keysystem' [SHIFT] 'Keysystem'
    keycode 59 = comma parenleft
    • The keycode 59 coresponds to the comma and less key (, & <).
    • The keysystem is what you want it to type e.g: comma, f, slash…etc.
    • The second argument is what is typed when holding the SHIFT_KEY (don’t write ‘[SHIFT]’).
  • Get the keycodes however you want. I used a tool called ‘xev’.
    • In the terminal run ‘xev’. Press a key, it’ll give you this:
    KeyRelease event, serial 38, synthetic NO, window 0x2000001,
    root 0x4a4, subw 0x0, time 2789210, (905,497), root:(1006,637),
    state 0x0, keycode 32 (keysym 0x6f, o), same_screen YES,
    XKeysymToKeycode returns keycode: 19
    XLookupString gives 1 bytes: (6f) "o"
    XFilterEvent returns: False
    • I typed ‘o’ (not zero), and voila keycode 32, and keysystem, ‘o’ (line 3).
  • When you’re done, run the script in the terminal
$ xmodmap ~/.Xmodmap

But you’ll have to run the command each time you login

I ran the command, and it was working. I was easily typing parentheses because, I switched it with less and greater ‘< & >’. But when I restarted the computer, my modifications were gone. I was back at doing chores typing parentheses. So now, every time I login, I have to open the terminal, and run the command.

Just kidding, you can make the command run automatically upon login. There are multiple ways on how to do it. I tried some, but only one worked for me.

  • This article explores 4 ways on how to do it.
  • This one here explains the whole process (change the keymapping and auto execute it) in-depth.
  • There is also a video.

However, what worked for me was over on stackoverflow.

  • Basically, make a bash scrpit (‘example.sh’), put the command in it:
#!/bin/sh
xmodmap ~/.Xmodmap

and make it executable

$ chmod +x /path/to/example.sh
  • Head over to this directory (/etc/xdg/autostart)
  • Create a file with ‘.desktop’ extension.
  • Put this code in it:
[Desktop Entry]
Name=MyScript
GenericName=A descriptive name
Comment=Some description about your script
Exec=/path/to/example.sh
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true
  • Don’t forget to replace /path/to/example.sh with the actual path.
  • Reboot your system, and there you have it.

Conclusion

I tried multiple methods that didn’t work for me. They might work for someone else. I think that curly braces get used more than square brackets, so that might have to change. Also, backslash could switch with asterisk. However, imagine the reaction of someone using my computer, priceless I know.

Top comments (0)