4

I'm trying to remap the Scroll Lock key so it produces the keycode of any of the Windows keys.

First of all, I dump the current keymap:

xkbcomp $DISPLAY original-dump

Then find the keycodes of the keys I'm interested in:

cat original-dump | grep SCLK
 <SCLK> = 78;

 cat original-dump | grep LWIN
 <LWIN> = 133;

Now I print the component names into a file:

setxkbmap -print > original-components

Edit the file to add my keycode modification:

    xkb_keymap {
    xkb_keycodes  { 
        include "evdev+aliases(qwerty)" 
        // Remap Scroll-lock to the keycode of LWIN(133)
        <SCLK> = 133;
    };
    xkb_types     { include "complete"  };
    xkb_compat    { include "complete"  };
    xkb_symbols   { include "pc+us+inet(evdev)" };
    xkb_geometry  { include "pc(pc105)" };
    };

Saved the file above as modified-components and run:

xkbcomp modified-components $DISPLAY

Dump again:

xkbcomp $DISPLAY original-dump

Check the keycodes:

cat another-dump | grep SCLK
<SCLK> = 133;

So far so good, but when I run xev, the keycode of the Scroll Lock key is still 78.

If I run:

xmodmap -e "keycode 78 = Super_L"

xev still shows me 78, but at least the shortcuts that I created in XFCE for the LWIN and RWIN work.

I would like to know what am I doing wrong with xkb. Thanks.

1 Answer 1

7

Tried the following new approach (with success)

Created a new file named sclkfile in the /usr/share/X11/xkb/symbols/ directory, and added the following contents:

 // Make the Scroll Lock key a left Super.
xkb_symbols "sclk_super" {
    replace key <SCLK> { [ Super_L ] };
    modifier_map  Mod4 { <SCLK> };
};

Added the new rule in /usr/share/X11/xkb/rules/evdev:

sclkoption:sclk_super = +sclkfile(sclk_super)

And descriptions of the rule in /usr/share/X11/xkb/rules/evdev.lst:

! option
sclkoption           Scroll Lock behaviour
sclkoption:sclk_super Scroll Lock is Super

Here too /usr/share/X11/xkb/rules/evdev.xml:

<configItem>
        <name>sclkoption</name>
        <description>Scroll Lock behaviour</description>
</configItem>    
<option>
    <configItem>
        <name>sclkoption:sclk_super</name>
        <description>Scroll Lock is Super</description>
    </configItem>
</option>

Finally run:

$ setxkbmap -option sclkoption:sclk_super

No errors, and when I print the components of my layout:

$ 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)+sclkfile(sclk_super)"     };
        xkb_geometry  { include "pc(pc105)"     };
};

The new rule is there.

Now, if I run xev:

keycode 78 (keysym 0xffeb, Super_R)

The keycode is still 78 but the keysym is Super_R. Success.

3
  • This is awesome. Finally a proper modern solution. … But my rules/evdev specifically states “do not edit”. As it is 1. part of the xkb-data package, installed via package manager, and will be overwritten, and 2. it is auto-generated from rules/*.part (probably inside the make script of that package). … Can this be done without changing any existing files? (Like a file is traditionally accompanied by a file.d directory to put such stuff in.)
    – anon
    Commented Aug 17, 2022 at 23:29
  • Apparently, such stuff goes in /etc/X11/xkb/. But how? Apart from straight-up reading the code or specification, xkb’s documentation is sadly, lacking, to say the least.
    – anon
    Commented Aug 18, 2022 at 0:29
  • Scroll Lock is Super. Scroll Lock is the best! Commented Dec 16, 2023 at 23:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .