Face it, cutting and pasting odd characters (such as á) can be a pain. To fix this, a program called xmodmap (it comes with X) can be used to help out. Basically, you can configure your computer to make it so that when an unused key, called a dead key (such as a windows key) is held down while pressing a normal key, instead of outputting the normal character, X11 will output the strange character. For instance, I have my computer configured that when I hold down the left windows key and press the "a" key, á is outputted.
First, determine which key you want to use as your dead key. Now, at a console, start the program xev. Press that key. Now close, xev, using only the mouse (don't use ALT-F4 or CONTROL-C). Although there will be some useless information after it, you should see something like the following:
Code: Select all
KeyRelease event, serial 30, synthetic NO, window 0x2400001,
root 0x8d, subw 0x0, time 8688866, (-93,-115), root:(730,348),
state 0x2000, keycode 115 (keysym 0xff7e, Mode_switch), same_screen YES,
XKeysymToKeycode returns keycode: 93
XLookupString gives 0 bytes:
Now, create a file, preferably with execute permissions, called "fix.sh". In it, add the following:
Code: Select all
#!/usr/bin/bash
xmodmap -e 'keycode 115 = Mode_switch'
Code: Select all
KeyPress event, serial 30, synthetic NO, window 0x2400001,
root 0x8d, subw 0x0, time 9014225, (792,179), root:(795,208),
state 0x0, keycode 38 (keysym 0x61, a), same_screen YES,
XLookupString gives 1 bytes: (61) "a"
XmbLookupString gives 1 bytes: (61) "a"
XFilterEvent returns: False
Now, you must determine what you want the computer to output if you hold down the deadkey and the other key. In addition, you need to determine what you want the computer to output if you hold down the deadkey, the shift key, AND the other key. The list of options can be found in the file /usr/include/X11/keysymdef.h.
Now append a line to "fix.sh" with the following format:
Code: Select all
xmodmap -e 'keycode KEYCODE = NORMAL_KEY KEY_WITH_SHIFT DEADKEY_AND_KEY DEADKEY_SHIFT_AND_KEY'
Repeat for all the other characters that you want. An example of a finished fix.sh is as follows, which can be used for inputting characters of the spanish language:
Code: Select all
xmodmap -e 'keycode 115 = Mode_switch'
xmodmap -e 'keycode 38 = a A aacute Aacute'
xmodmap -e 'keycode 26 = e E eacute Eacute'
xmodmap -e 'keycode 31 = i I iacute Iacute'
xmodmap -e 'keycode 32 = o O oacute Oacute'
xmodmap -e 'keycode 30 = u U uacute Uacute'
xmodmap -e 'keycode 57 = n N ntilde Ntilde'
xmodmap -e 'keycode 61 = slash question questiondown questiondown'
xmodmap -e 'keycode 10 = 1 exclam 1 exclamdown'
Note that typing a key that you did not specify while holding down the deadkey will result in an odd character being outputted.




