You are not logged in.

#1 2009-07-11 00:54:49

onguarde
Member
Registered: 2008-09-14
Posts: 144

Xmodmap Modifier act as Toggle - Map to Mode_Switch_Lock

Peace all!

Is there a way to make the mode_switch key act as a toggle?

I found this from the a link in the emacs wiki.
http://www.tldp.org/HOWTO/Keyboard-and- … TO-15.html

"Can the Shift, Ctrl and Alt keys be made to behave as toggles?"

Yes, after saying

            % loadkeys
            keymaps 0-15
            keycode 29 = Control_Lock
            keycode 42 = Shift_Lock
            keycode 56 = Alt_Lock
            %

First of all, I can only run the program in console and not in X which is fine.

% loadkeys
keycode 108 = Control_Lock
(null):2: syntax error
syntax error in map file
key bindings not changed

I keep getting the above errors. Any loadkeys gurus out there?

Also, I read in the arch linux installation guide, it states that loadkeys only applies in console mode.

KEYMAP: Defines the keymap to load with the loadkeys program on bootup. Possible keymaps are found in /usr/share/kbd/keymaps. Please note that this setting is only valid for your TTYs, not any graphical window managers or X! Again, the default is fine for US users

Offline

#2 2009-07-11 08:24:07

djszapi
Member
From: Cambridge, United Kingdom
Registered: 2009-06-14
Posts: 1,439
Website

Offline

#3 2009-07-11 15:46:06

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: Xmodmap Modifier act as Toggle - Map to Mode_Switch_Lock

You can call a script every time a key is pressed that does something based on its current state. A script like this will work. It simply creates or removes an empty file in the /tmp directory. If the file exists, then the key is in one state. If the file doesn't exist, it's in another. I just called the temp file mod_key_state for this example:

#!/bin/bash

if [ ! -f /tmp/mod_key_state ]
then
    
    touch /tmp/mod_key_state

    *** DO SOMETHING***

else

    *** DO SMOTHING ELSE ***
    
    rm /tmp/mod_key_state
fi

Offline

#4 2009-07-12 06:31:49

onguarde
Member
Registered: 2008-09-14
Posts: 144

Re: Xmodmap Modifier act as Toggle - Map to Mode_Switch_Lock

Doesn't that seem a little overkill?

The weird thing is the webby above seems to indicate an "inbuilt" functionality.

Offline

#5 2009-07-12 18:42:53

abesto
Member
From: Hungary
Registered: 2009-03-05
Posts: 49
Website

Re: Xmodmap Modifier act as Toggle - Map to Mode_Switch_Lock

`man xmodmap` says that a list of keysym names can be found in keysymdef.h. `grep "_Lock" /usr/include/X11/keysymdef.h` returns only Shift_Lock of those used in your example, so that may be a problem.


Linux user #476135 || Dotfiles hosted by GitHub

Offline

#6 2009-07-13 02:16:33

alterecco
Member
Registered: 2009-07-13
Posts: 152

Re: Xmodmap Modifier act as Toggle - Map to Mode_Switch_Lock

If I understand your question correctly, what you want to use is ISO_Next_Group and ISO_Prev_Group.

A small example of how that would work with xmodmap

! remap caps_lock to do mode switching
remove Lock = Caps_Lock
keycode 66 = Mode_switch ISO_Next_Group Mode_switch ISO_Next_Group

!                       --- GROUP 1 ----                  ---- GROUP 2 ----

keycode  43 =   h                H                      Left            Home
keycode  44 =   j                 J                      Down          Next
keycode  45 =   k                K                      Up              Prior
keycode  46 =   l                 L                      Right           End

This small snippet remaps the hjkl keys (on my keyboard at least. Check xev for the correct keycodes).
When you hold down the remapped Caps_Lock, you switch temporarily to the next group, allowing arrow movement on yout hjkl keys. If you press Shift+Caps_Lock (ISO_Next_Group), then you move to the next group, allowing access to the Group 2 keys without holding a modifier down. In that mode, shift would invoke Prior, Next, Home, End, and Shift+Caps_Lock would switch to the next group (Group 1). You can have more than 2 groups, and of course, you can bind your Mode_switch and ISO_* to whatever you like.

This will allow for a very complex and customized key layout, with many layers. If you are into power remapping, and like to learn a new layout, have a look at Neo, a subset of the de (german) layout. It is excellent to study to see what can be done with your keyboard.

Hope this helps.

.]

Offline

#7 2009-07-14 13:39:23

onguarde
Member
Registered: 2008-09-14
Posts: 144

Re: Xmodmap Modifier act as Toggle - Map to Mode_Switch_Lock

Thanks for the reply!

I've seen some of that and its especially useful for inputting multiple languages seamlessly. In my case, for a quick secondary modifier, the mode switch is enough. Only problem is I find myself continuously pressing my capslock(modeswitch) with my pinky throughout the use of "IJKL" arrow keys. Thought it might be useful to  have it as a toggle instead.

Offline

#8 2009-07-14 14:46:53

alterecco
Member
Registered: 2009-07-13
Posts: 152

Re: Xmodmap Modifier act as Toggle - Map to Mode_Switch_Lock

onguarde wrote:

Only problem is I find myself continuously pressing my capslock(modeswitch) with my pinky throughout the use of "IJKL" arrow keys. Thought it might be useful to  have it as a toggle instead.

I thought the same originally. In the end I found that I need the switch too often to have it as a group switch. If the pinky bothers you, try using one of the Alt keys. If you have a keyboard with nice big Alt keys they are usually placed conveniently under the thumb. Then make the capslock a mod key, or control key (as it should be!). For inputting multiple languages I find myself liking Xcompose alot.

Offline

Board footer

Powered by FluxBB