Map right alt to left control

The keycodes file you've changed is an XKB mapping that defines the symbol codes used in XKB layouts (<FOO>) by the keycodes emitted by the kernel keyboard driver when a key is pressed. Changing the codes there doesn't change what code the key generates, it changes what code the XKB layout thinks its dealing with when it sees the altered symbol.

Assuming you can get your system XKB files back to their original state, the XKB way to do what you want is to load an option that will override the standard layout. There's an existing option (ctrl:ralt_rctrl) that's close to what you want:

  # definition in /usr/share/X11/xkb/rules/evdev
  ctrl:rctrl_ralt       =       +ctrl(rctrl_ralt)
  # similar rule for swapped option?
  ctrl:ralt_rctrl       =       +ctrl(ralt_rctrl)

You can load that with setxkbmap:

$ setxkbmap -option ctrl:ralt_rctrl

If that does what you want, you can make it permanent by adding that command to a .xprofile or .xinitrc or your window manager's autorun script. In GNOME you may need other steps.

If you still prefer to have Alt_R remapped as Ctrl_L instead of Ctrl_R, you'd want to create a local override clause. Use the existing option as a starting point; it's in /usr/share/X11/xkb/symbols/ctrl. See my superuser answer on XKB modifications and some additional resources:

  • http://madduck.net/docs/extending-xkb/
  • http://apps.jcns.fz-juelich.de/doku/sc/xkbmap
  • https://wiki.archlinux.org/index.php/Keyboard_configuration_in_Xorg
  • Where is Xkb getting its configuration?
  • https://askubuntu.com/questions/451945/permanently-set-keyboard-layout-options-with-setxkbmap-in-gnome-unity