You are not logged in.

#1 2013-01-22 19:58:27

rogue
Member
Registered: 2011-08-03
Posts: 68
Website

[solved] Xmodmap change Caps Lock into F13 issues

Hello,

I am trying to use Xmodmap to turn off Caps Lock and use the key as F13 for the sake of having another modifier for Openbox keybindings. Over a year ago I had this working just fine when I was using Ratpoison. I also posted in November 2012 about it here, although I did not receive any replies. I just can't seem to figure out what I am doing wrong here.

References:
Xmodmap Man Page | Xmodmap - Arch Wiki

Openbox rc.xml keybind:

   <keybind key="F13-x">
      <action name="Execute">
         <startupnotify>
            <enabled>true</enabled>
            <name>Dmenu</name>
         </startupnotify>
         <command>dmenu_run</command>
      </action>
   </keybind>

Current .Xmodmap:

clear Lock
keycode 66 = F13

In it's current configuration, say I have the terminal focused, the following is printed as input:

~x

If GVim is focused, this is what is printed:

<F13>x

How do I turn F13 into an 'escape' key so that I am able to use it as a modifier, while completely disabling the original function of Caps Lock?

EDIT
I've also tried the following in .Xmodmap with the same results as above:

clear Lock
keysym Caps_Lock = F13
$ xmodmap -pke | grep -i F13
keycode  66 = F13 NoSymbol F13

EDIT 2
I've tried mapping other F keys (F20 for example) with the same condition as above. Using "remove Lock = Caps_Lock" seems to work the same as "clear Lock" by the way. I'm fairly certain that my Openbox configuration is set up right, as I had dmenu popping up when I was using the Ctrl key as the modifier. Ctrl-x just isn't going to work though as it is mapped for other programs.

I'm open to new ideas about how to do this if mapping F13 is not feasible.

Last edited by rogue (2013-01-23 04:32:47)

Offline

#2 2013-01-22 23:11:24

CommanderC
Member
Registered: 2012-10-31
Posts: 14

Re: [solved] Xmodmap change Caps Lock into F13 issues

Openbox can't use Lock as a modifier for its keybindings, but it's possible to use Mod3 (and F13 can be Mod3). Replace "F13-x" with "Mod3-x" in rc.xml.

To add F13 to the Mod3 modifier map:

  xmodmap -e 'clear Mod3'
  xmodmap -e 'add Mod3 = F13'

Run 'xmodmap -pm' to verify that Mod3 has the value you want.

Offline

#3 2013-01-22 23:33:26

rogue
Member
Registered: 2011-08-03
Posts: 68
Website

Re: [solved] Xmodmap change Caps Lock into F13 issues

I'm not actually using Lock as my modifier in Openbox though. I'm trying to remap F13 to the Caps Lock key so that when I press Caps Lock, it actually represents F13. In your example, what would key would I press to represent Mod3? I don't actually have an F13 key on my keyboard.

Offline

#4 2013-01-22 23:46:48

WombleGoneBad
Member
Registered: 2012-01-06
Posts: 8

Re: [solved] Xmodmap change Caps Lock into F13 issues

Hiya,
i dont know if this is the same problem, but i had something similar a while back.
First of all use 'xev' (pacman -S xorg-xev) it is very usefull for seeing what keysym your keys are mapped to.

Now, my own particular problem was that i was running software (ibus chinese input in my case) that re-loaded the keymap. If you have ibus (or similar) xmodmap just WONT WORK.
my solution was not to use xmodmap, but the modify the appropriate xkb mapping file
(for me this was /usr/share/X11/xkb/symbols/gb but it will likely be a different place for you as per your keyboard mapping)  in the  function for the keyboard layout i knew it was using, i added a line

key <FK05> {[Insert, Insert, Insert, Insert]};

(in my case i wanted to map the F5 key to behave as the 'Insert' key as my keyboard had no Insert key, and i use shift+insert for 'paste' in xterm a lot)
In your case i believe it would be

key <CAPS> {[F13]};

This solved it for me. arch has some good docs on xkb too you can look at.

I guess your problem might be something completely different, but i think something like this is certainly worth a try. Oh and you can go 'earlier' and remap the keycode to something other than <CAPS> (ie. map keycode to <FK13> instead) , but I didn't have to go that far.

Offline

#5 2013-01-22 23:52:24

altercation
Member
From: Seattle
Registered: 2011-05-15
Posts: 135
Website

Re: [solved] Xmodmap change Caps Lock into F13 issues

This works here in testing (in, say, a bash script or on the command line)

setxkbmap -option # reset everything to default state!
xmodmap -e "remove Lock = Caps_Lock"
xmodmap -e "keysym Caps_Lock = F13"

Ethan Schoonover
Precision Colors - http://ethanschoonover.com/solarized

Offline

#6 2013-01-23 00:45:32

rogue
Member
Registered: 2011-08-03
Posts: 68
Website

Re: [solved] Xmodmap change Caps Lock into F13 issues

altercation wrote:

This works here in testing (in, say, a bash script or on the command line)

setxkbmap -option # reset everything to default state!
xmodmap -e "remove Lock = Caps_Lock"
xmodmap -e "keysym Caps_Lock = F13"

Did you try it with an openbox keybind? If so, did it launch or do whatever behavior you set it for? I mean, with your configuration, Xmodmap doesn't throw me any errors, it just doesn't seem to be working for some reason.

WombleGoneBad, I'm not really sure where I have to add that line to.

 setxkbmap -print
xkb_keymap {
	xkb_keycodes  { include "evdev+aliases(qwerty)"	};
	xkb_types     { include "complete"	};
	xkb_compat    { include "complete"	};
	xkb_symbols   { include "pc+us+inet(evdev)"	};
	xkb_geometry  { include "pc(pc104)"	};
};

I opened the 'us' file in nano, but I couldn't find a good place to add "key <CAPS> {[F13]};". I think I need to figure exactly what keyboard I am using somehow.

Offline

#7 2013-01-23 01:52:57

altercation
Member
From: Seattle
Registered: 2011-05-15
Posts: 135
Website

Re: [solved] Xmodmap change Caps Lock into F13 issues

I'm on xmonad, so ymmv. However, I'd recommend simplifying your test. Turn something you aren't going to miss into something else, e.g. (temporarily) a curly bracket into an X. Make this a test of known quantities. Good luck.


Ethan Schoonover
Precision Colors - http://ethanschoonover.com/solarized

Offline

#8 2013-01-23 04:31:39

rogue
Member
Registered: 2011-08-03
Posts: 68
Website

Re: [solved] Xmodmap change Caps Lock into F13 issues

Alright, so I somewhat have this figured out. After doing a bit more reading, I finally figured out that Openbox only accepts a few keys to be used as "Modifiers". F keys are not one of them. By shortening my keybind in rc.xml to just "F13", dmenu appears. I don't know why I didn't try this earlier. Therefore, Xmodmap has been working fine all along, and I wasted hours on an assumption. Altercation, your comment caused me to simplify my problem which led to my discovery. Thank you all. For the sake of documentation, this works:

<keybind key="F13">
      <action name="Execute">
         <startupnotify>
            <enabled>true</enabled>
            <name>Dmenu</name>
         </startupnotify>
         <command>dmenu_run</command>
      </action>
</keybind>

Last edited by rogue (2013-01-23 04:32:00)

Offline

Board footer

Powered by FluxBB