Linux – Why is the Scroll Lock key disabled in Cinnamon/Linux/Xorg

arch linuxcinnamonxorg

I recently purchased a backlit keyboard that was designed such that the Scroll Lock key was used to toggle the back light. I quickly found that Cinnamon does not respond properly when the Scroll Lock key is pressed. Originally, I thought the keyboard backlight was DOA because everything else worked out of the box. After a reboot I found that before launching Xorg I was able to successfully toggle the backlight using the Scroll Lock key. Then, once again, after starting Xorg (and consequentially cinnamon_session), this functionality stopped working once again.

In order to get the backlight working after launching Xorg I was forced to issue a: xset led named "Scroll Lock" to enabled and disable this functionality.

After a bit of research I came across a program called xev that dumped key event information to the terminal after it was started. Upon pressing the Scroll Lock key the terminal was populated with this information:

KeyPress event, serial 34, synthetic NO, window 0x2c00001,
root 0x2df, subw 0x0, time 2609824, (410,0), root:(1724,142),
state 0x0, keycode 78 (keysym 0xff14, Scroll_Lock), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x2c00001,
root 0x2df, subw 0x0, time 2609912, (410,0), root:(1724,142),
state 0x0, keycode 78 (keysym 0xff14, Scroll_Lock), same_screen YES,
XLookupString gives 0 bytes:

So I know the key event is being sent to the kernel.

Also, interestingly, I observed strange behavior when in the terminal (still prior to launching Xorg or Cinnamon) and using Scroll Lock. Namely, at this point my backlight was toggling as expected, but when Scroll Lock was enabled nothing I typed was written to the screen. After disabling Scroll Lock everything I had written was immediately dumped to the terminal as if it was previously being buffered.

tl;dr What is the deal with Scroll Lock and Xorg?

Best Answer

I'm not familiar with Cinnamon, but it should be possible to enable your Scroll Lock key.

First, we need to see if you have a spare keyboard modifier slot. Run:

xmodmap -pm

That will print a list of your current modifier setup. Hopefully, one of those lines won't have any keys listed; generally that will be mod3. Assuming that's the case, you can enable Scroll Lock with this command:

xmodmap -e "add mod3 = Scroll_Lock"

Your Scroll Lock LED should now respond to Scroll Lock key presses.

If that works, you probably want X to do that automatically whenever it starts. There are various ways to do that: it can be done on a per user basis, but for something like this I think it makes sense for it to be set globally.

But I've never done this before myself, so I'd better test it before giving further details. :)

OK. The method I tried to activate that modmap globally doesn't work for me on KDE. :( But activating it in my home directory seems to work OK.

Create a file called .Xmodmap in your home directory containing this line:

add mod3 = Scroll_Lock

The easiest way to do that is:

cd ~
echo >.Xmodmap "add mod3 = Scroll_Lock"

Now restart X (logout & login again). Hopefully, your Scroll Lock key will be working. If it doesn't, please let me know.