Link to home
Start Free TrialLog in
Avatar of bryanlloydharris
bryanlloydharris

asked on

how to use .Xdefaults file for keymaps

Hi,

In the xterm man pages I can see the following text towards the end.  It seems that X should insert the text (i.e. next, step, continue, etc.) whenever I press the F-key.  However, when I add this code to my .Xdefaults and then run "xdrb -merge .Xdefaults" I am not able to press the F-key.

In my config I changed the F-keys to something lower, such as F7, but it still did not work.

           *VT100.Translations: #override <Key>F13: keymap(dbx)
           *VT100.dbxKeymap.translations: \
                <Key>F14: keymap(None) \n\
                <Key>F17: string("next") string(0x0d) \n\
                <Key>F18: string("step") string(0x0d) \n\
                <Key>F19: string("continue") string(0x0d) \n\
                <Key>F20: string("print ") insert-selection(PRIMARY, CUT_BUFFER0)

Can someone please tell me how to enable this?  I would like to press the F-key for doing commands.

Avatar of bryanlloydharris
bryanlloydharris

ASKER

Here is what happens when I press the F-key a few times.  It just types 8~ instead of typing the desired text.

$ 8~8~8~8~8~8~
ASKER CERTIFIED SOLUTION
Avatar of pjedmond
pjedmond
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi, I actually figured it out with great effort.  It's just that the X resources database is difficult for me to understand.

I was starting to wonder if I could send similar strings to firefox when I read your answer --- thanks for the tip!  I will probably end up throwing out the use of .Xdefaults and just stick with crikey if it works for me.  Have you had good experience with it?

Anyway, if you're curious, here is the final result of my efforts.  With the following code in .Xdefaults you must _first_ press F1 to "activate" the other lines of code --- at least that's my basic understanding.  Once you have pressed F1, you may press one of the other combos and its associated string will be inserted on the xterm CLI.

I thought it would be cool if I could type something like *firefox.Translations: to do a keymap in firefox but I'll just leave that in the back of my mind for later.  It also doesn't really seem worth looking up if that crikey program ends up working.

What I had to do to get it work was:
0) create the .Xdefaults file and put in the code
1) run "xrdb -merge .Xdefaults"
2) close my xterm
3) open a new xterm
4) press F1
5) then press one of the others and voila it worked.

*VT100.Translations: #override <Key>F1: keymap(function)
*VT100.functionKeymap.translations: \
    <Key>F2: string("some string here\n") \n\
    <Key>F3: string("another string here\n") \n\
    <Key>F4: string("and yet another string here\n") \n\

Never used crikey before today - Was gradually ripping out my hair trying to get it to work and found this little utility (with reasonably clear instructions). Got what I wanted working in about 10 mins:) Thanks for your explaination - I can get it working on my system with the .Xdefaults now - but it's a bit fiddly....but then again, it's probably something that you'd normally only do once!

Many thanks for the points

(   (()
(`-' _\
 ''  ''