• experiments with xmodmap

    From Spiros Bousbouras@21:1/5 to All on Fri Apr 28 15:06:33 2023
    I have a Cherry QWERTY keyboard which has the usual keys and some unusual
    ones which include a key with a calculator symbol on it. I will be referring
    to this as CalcKey. CalcKey doesn't do anything as a default so I decided to experiment with making it do something. xev says that it has keycode 161. After some experiments where I wasn't getting exactly what I was expecting ,
    I decided to make CalcKey reproduce precisely the behaviour or a preexisting key , in particular the following line from the output of xmodmap -pke :

    keycode 19 = 0 parenright braceright degree braceright degree

    The specific key (which is the common 0 key on top of a QWERTY keyboard) produces

    No modifier 0
    Shift )
    Control 0
    Alt (degree symbol , code 176 in ISO-8859-1)
    AltGr }

    (My keyboard also has 2 keys with the MS Windows logo but I don't know if
    these count as modifier keys. They don't seem to modify the output of any
    key but xev says they are Super_L and Super_R .Anyway , they are not
    very relevant to this question)

    So I did

    xmodmap -e 'keycode 161 = 0 parenright braceright degree braceright degree'

    Now CalcKey gives

    No modifier 0
    Shift )
    Control 0
    Alt (degree symbol , code 176 in ISO-8859-1)
    AltGr 0

    Note the difference with what the 0 key produces. So do you have any explanation as to what is happening ?

    xmodmap -pke | grep braceright
    gives
    keycode 19 = 0 parenright braceright degree braceright degree
    keycode 35 = bracketright braceright dead_tilde dead_macron dead_tilde dead_macron
    keycode 161 = 0 parenright braceright degree braceright degree

    so my modification seems to have succeeded. Nonetheless , the 2 keys do not behave the same. I get the different behaviour between 0 key and CalcKey with
    2 different terminal emulators and graphical vim .

    And some related questions : can I give xmodmap an octet to output ? For example

    a=$'\141' ; xmodmap -e "keycode 161 = $a"

    works and makes CalcKey output a but

    a=$'\377' ; xmodmap -e "keycode 161 = $a"

    produces

    xmodmap: commandline:1: bad keysym name '' in keysym list
    xmodmap: 1 error encountered, aborting.


    Which Xlib man pages should I look at to understand the mechanisms
    involved at a deeper level ? In particular which Xlib function
    does xmodmap use to edit the modifier map ? XRebindKeysym() only
    modifies what's happening for the application which called it.

    --
    The trouble with programmers is that you can never tell what a
    programmer is doing until it's too late.
    Seymour Cray

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eli the Bearded@21:1/5 to spibou@gmail.com on Fri Apr 28 20:26:32 2023
    In comp.windows.x, Spiros Bousbouras <spibou@gmail.com> wrote:
    I have a Cherry QWERTY keyboard which has the usual keys and some unusual ones which include a key with a calculator symbol on it. I will be referring to this as CalcKey. CalcKey doesn't do anything as a default so I decided to experiment with making it do something. xev says that it has keycode 161. After some experiments where I wasn't getting exactly what I was expecting , I decided to make CalcKey reproduce precisely the behaviour or a preexisting key , in particular the following line from the output of xmodmap -pke :

    keycode 19 = 0 parenright braceright degree braceright degree

    My xmodmap manpage says up to eight keysyms can be assigned to a keycode
    but "the last four are not used in any major X server implementation."
    This may be a case of the documentation being out of date.

    The specific key (which is the common 0 key on top of a QWERTY keyboard) produces

    No modifier 0
    Shift )
    Control 0
    Alt ° (degree symbol , code 176 in ISO-8859-1)
    AltGr }

    (My keyboard also has 2 keys with the MS Windows logo but I don't know if these count as modifier keys. They don't seem to modify the output of any
    key but xev says they are Super_L and Super_R .Anyway , they are not
    very relevant to this question)

    The xev output is telling you, yes, those are modifiers.

    So I did

    xmodmap -e 'keycode 161 = 0 parenright braceright degree braceright degree'

    Now CalcKey gives

    No modifier 0
    Shift )
    Control 0
    Alt ° (degree symbol , code 176 in ISO-8859-1)
    AltGr 0

    Note the difference with what the 0 key produces. So do you have any explanation as to what is happening ?

    I don't know, but I suspect that something is happening on a different
    layer than xmodmap operates.

    And some related questions : can I give xmodmap an octet to output ? For example

    Use Uxxxx for four digit Unicode codepoints or Uxxxxxx for six digit
    Unicode codepoints.

    Which Xlib man pages should I look at to understand the mechanisms
    involved at a deeper level ? In particular which Xlib function
    does xmodmap use to edit the modifier map ? XRebindKeysym() only
    modifies what's happening for the application which called it.

    I can't say for sure. I'd start looking at the source for xmodmap and
    xev for changing them and looking up them. I know I have seen xev
    versions that can look up modifiers and keysyms for keyboard events.

    Elijah
    ------
    has modified xev for personal use in the past

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)