Skip to content

Instantly share code, notes, and snippets.

@Simhyeon
Last active September 17, 2022 08:26
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Simhyeon/9ec0bfed40445afcd647bf7c02995aab to your computer and use it in GitHub Desktop.
Save Simhyeon/9ec0bfed40445afcd647bf7c02995aab to your computer and use it in GitHub Desktop.
Xmodmap example
! # NOTE
!
! For asian users, this keymappings will not work when typing in your native
! language. You need a separate article to understand why that doesn't work,
! yet you can use keyd or kmonad if you need low-level global key mapping.
! I personally recommend using keyd if you are not familar with lisp-like
! languages.
!
! - Keyd repository : https://github.com/rvaiya/keyd
! - My config for keyd : https://gist.github.com/Simhyeon/58b008a9a5d8e8b34d78d774db1f745b
!
! If you want to change .Xmodmap by your flavor refer to the table in the
! bottom of this file. Also Arch wiki is a great resource.
! https://wiki.archlinux.org/index.php/Xmodmap
!
! # How to get keycode
!
! Keycode can be detected with xev command. Simply open up your terminal and
! type "xev" to find out. Search for Key even block which contains keycode
!
! Especially use a command 'xev | grep --line-buffered keysym' if you want some
! intuitive keypress sequences.
!
! # How to use xmodmap
!
! Simply run "xmodmap .Xmodmap" in your shell. If yout want the script to be
! ran automatcially on boot, use system service or startup script preferrably
! time intervals.
!
! # Abstract
!
! Below is a short description for my keymappings
! <keyname> for <explanation>
! ----------- Generics --------------
! <Alt_L> for Mode_switch key
! <p> for Plus
! <h> for home
! <;> for end
! <i, j, k, l> for (up, left, down, right) respectively
! <y> for Esc or escape key
! <u> for Backspace key
! <o> for Delete key
! <n> for Pageup or prior key
! <m> for Page down or Next key
! <q> for Backslash
! <w> for Minus
! <e> for Equal
! <r> for tilde
! <t> for grave(`)
! <a> for Ampersand
! <s> for Asterisk
! <d> for Dollar
! <f> for Percentage
! <z> for exclamation mark
! <x> for at(@)
! <c> for numbersign(#)
! <v> for Carret(^)
! <b> for F6
! <,> for underscore(_)
! <.> for Greater than(>)
!
! ## Left keyboard numpad
! Q W E for 1 2 3
! A S D for 4 5 6
! Z X C for 7 8 9
!
! ## Right keyboard numpad
! P { } for 7 8 9
! L : " for 4 5 6
! < > ? for 1 2 3
! # Clear keys
! You should clear special key that you want to change bofore assign other keys
!
! Clear special keys(left_alt) and reassign it as mod switch key
clear mod1
keycode 64 = Mode_switch
! # Mapping
! Set custom key mapping
! Key mapping are separated by whitespaces and a syntax is quite lenient
! Key code mapping table's format is in the next line.
! ---------------------------------------------------------------------
! keycode |normal |shift |mode+key |mode+shift+key
! ---------------------------------------------------------------------
keycode 24 = q Q backslash 1
keycode 25 = w W minus 2
keycode 26 = e E equal 3
keycode 27 = r R asciitilde
keycode 28 = t T grave
keycode 29 = y Y Escape
keycode 30 = u U BackSpace
keycode 31 = i I Up
keycode 32 = o O Delete 0
keycode 51 = backslash bar backslash 0
keycode 33 = p P plus 7
keycode 34 = bracketleft braceleft bracketleft 8
keycode 35 = bracketright braceright bracketright 9
keycode 38 = a A ampersand 4
keycode 39 = s S asterisk 5
keycode 40 = d D dollar 6
keycode 41 = f F percent
keycode 42 = g G colon
keycode 43 = h H Home
keycode 44 = j J Left
keycode 45 = k K Down
keycode 46 = l L Right 4
keycode 47 = semicolon colon End 5
keycode 48 = apostrophe quotedbl apostrophe 6
keycode 52 = z Z exclam 7
keycode 53 = x X at 8
keycode 54 = c C numbersign 9
keycode 55 = v V asciicircum
keycode 56 = b B F6
keycode 57 = n N Prior
keycode 58 = m M Next
keycode 59 = comma less underscore 1
keycode 60 = period greater greater 2
keycode 61 = slash question slash 3
! ---------------------------------------------------------------------
! # Reassign special keys
! and after assinging you sould assign functionatly again
! Still doesn't get about the mechanism in here, but it works anyway... so yeah
add mod1 = Alt_L Alt_R
! # Reference
! Table of keycode(number) and keysms(name)
! ---------------------------------------------------------------------
! keycode |normal |shift |mode+key |mode+shift+key
! ---------------------------------------------------------------------
! keycode 10 = 1 exclam
! keycode 11 = 2 at
! keycode 12 = 3 numbersign
! keycode 13 = 4 dollar
! keycode 14 = 5 percent
! keycode 15 = 6 asciicircum
! keycode 16 = 7 ampersand
! keycode 17 = 8 asterisk
! keycode 18 = 9 parenleft
! keycode 19 = 0 parenright
! keycode 20 = minus underscore
! keycode 21 = equal plus
! keycode 22 = BackSpace
! keycode 23 = Tab
! keycode 24 = q Q
! keycode 25 = w W
! keycode 26 = e E
! keycode 27 = r R
! keycode 28 = t T
! keycode 29 = y Y
! keycode 30 = u U
! keycode 31 = i I
! keycode 32 = o O
! keycode 33 = p P
! keycode 34 = bracketleft braceleft
! keycode 35 = bracketright braceright
! keycode 51 = backslash bar
! keycode 38 = a A
! keycode 39 = s S
! keycode 40 = d D
! keycode 41 = f F
! keycode 42 = g G
! keycode 43 = h H
! keycode 44 = j J
! keycode 45 = k K
! keycode 46 = l L
! keycode 47 = semicolon colon
! keycode 48 = apostrophe quotedbl
! keycode 36 = Return
! keycode 52 = z Z
! keycode 53 = x X
! keycode 54 = c C
! keycode 55 = v V
! keycode 56 = b B
! keycode 57 = n N
! keycode 58 = m M
! keycode 59 = comma less
! keycode 60 = period greater
! keycode 61 = slash question
@Simhyeon
Copy link
Author

Well darn it. Can't figure why indent is a mess.

@KyuDounSim
Copy link

Thank you so much for sharing this. I probably don't have a good understanding of how xmodmap still works, but does alt+tab work for you to switch between different windows?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment