12

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?

  • Any luck resolving this issue @sherrellbc? – Pykler Mar 17 '15 at 4:25
9

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.

  • The .Xmodmap config did not work for me on Ubuntu 16.04 / Unity, but the permanent solution in the answer of of Pykler worked :) – Nebel54 Mar 15 '18 at 9:19
7

Found the permanent way after a long night up with lots of half baked solutions.

# backup your symbols file
sudo cp /usr/share/X11/xkb/symbols/us{,.distribution} 

Add the following line in the xkb_symbols "basic" { section. do not worry if that second line is not there, it is only there for some languages and was not there for us on my system.

...
    modifier_map Mod3   { Scroll_Lock }; <==<< Add this line

    include "level3(ralt_switch)" <==<< before this line
};

You may have to do the same in your other layouts if you switch between languages

Also, there is a cache where xkb layouts live. You should clear it before restarting your X server to check the new keyboard symbol file(s).

sudo rm -f /var/lib/xkb/*
2

As Scroll Lock may interfere with your keyboard shortcuts when active (named F12, Ctrl+Space won't work as expected), I decided to match the Scroll Lock key to a manual launch of xset, toggling the LED state regarding it previous state.

I created an executable script named toggle_keyb_led.sh:

xset q | awk '/LED/{ if ($10 ~ "00000000") print "led"; else print "-led" }' | xargs xset

This parses the output of xset q, matching the line with LED mask.

Note 1: If doesn't work for you, please verify with xset -led; xset q | grep 'LED' what is the current mask value.

Note 2: Some users need to run xset led 3 to activate the light. In this case, please rewrite above script.


Then you can launch this script as Custom Shortcut using your Desktop Environment like (here is with a Cinnamon):

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.