3

I have a computer with Fedora 16 and KDE. It's connected through a KVM switch to a monitor with another computer, and the switch uses Scroll Lock + Scroll Lock to switch between the computers.

The problem is that for some reason the Scroll Lock button doesn't work on Fedora/KDE. Num Lock and Caps Lock work. The command xset q says that it's off, and xset led named "Scroll Lock" does turn it on, but I can't "double-click".

How can I check why the button isn't working and resolve the problem? I have looked everywhere and haven't found anyone with this specific problem.

2 Answers 2

6

I once was pulling my hair out for a while trying to figure this out. Apparently, Scroll Lock isn't by default detected by X so you have to make it recognize and detect that key, if you are in that boat.

  1. Open a terminal.

  2. Run xmodmap -pm to check which mod keys are available. Usually there is at least one. In my case mod3 was available. So I would run the following (your available mod key may differ, so use that number when you run the next command).

  3. Run xmodmap -e 'add mod3 = Scroll_Lock' and the Scroll Lock key should begin working in X.

  4. To make this permanent, you can add a startup item in your window manager/environment or use another method like putting that in your .xinitrc file or create a file in xinitrc.d to do that (if these still work for your distribution of Linux, or use another method if they don't).

UPDATED: I just noticed that after some updates my previous method of invoking xmodmap using a startup item ceased to function. I was using an addition to the Startup Applications Preferences. Since that way of doing that now is added to the other ways in which this command has been broken I add the following for Fedora 21 and later. It also should work for a number of other distributions as well, but YMMV.

To make the above permanent, do the following:

  1. Use your available mod number obtained from the above if it differs from mod3 below, or check again to see which one is available by running:

xmodmap

We'll assume that it gave mod3 as the available slot for the purposes of this guide.

  1. Create a script in the /usr/local/bin directory called scrlkon.

sudo touch /usr/local/bin/scrlkon

  1. Open the file you just created (you can use your favorite text editor in place of nano if you like).

sudo nano /usr/local/bin/scrlkon

  1. Put the following text into the file:

#!/usr/bin/sh

sleep 4

exec xmodmap -e 'add mod3 = Scroll_Lock'

exit

  1. Save the file and make it executable:

sudo chmod +x /usr/local/bin/scrlkon

  1. Call the script from a Startup item.

You can name that new startup item whatever you like so long as it calls scrlkon

  1. Reboot if it doesn't start right away when you logoff and logon again.

Note: You may wish to adjust the sleep number to more than 4 if needed. Calling the sleep function is necessary to counteract whatever it is that is turning off the mod key or disabling the xmodmap command on logon. 4 is a good number as it doesn't take that long after logon to work. But if it still gets disabled by something in the Fedora environment (this is particularly bad in mate-desktop for some reason) just increase the number in sleep until your get the key enabled consistently. That should do it.

An alternative to doing it the above way (if you don't want to make a script or add other files) is to substitute the following in the Command field in the Startup Program item in alternate steps 2-6:

sh -c "sleep 15; exec xmodmap -e 'add mod3 = Scroll_Lock'"

This seems to work as well. Just make sure that the single and double quotes are straight and not curly quotes.

2
  • Thanks, I upvoted your comment because it seems like the correct solution, even though the setup I'm using now is different and the question is no longer relevant for me specifically. Hopefully someone else finds this useful.
    – Ynhockey
    Commented Nov 3, 2014 at 10:58
  • Dude! You are the man. Needed this to make my cm devastator keyboard backlight work on Fedora 21.
    – penner
    Commented Dec 21, 2014 at 2:40
1

I have a similar KVM switch and, since I don't want to have something running in the background poking xmodmap periodically and haven't yet modified the X keymap, my solution was this script:

#!/bin/bash
# Toggle the KVM switch programmatically by toggling the Scroll Lock LED
# Based on https://askubuntu.com/a/546989/23552

SLEEP=0.5
LEDNAME="Scroll Lock"

echo "Switching..."
xset led named "$LEDNAME"
sleep $SLEEP
xset -led named "$LEDNAME"
sleep $SLEEP
xset led named "$LEDNAME"
sleep $SLEEP
xset -led named "$LEDNAME"

(Yeah, it's technically quadruple-tapping the key. I'm not sure if my delay is too short, but I found double-tapping to be unreliable and this works, so... good enough for now.)

Then, to switch from my daily driver to my "no background tasks to stutter things up" gaming machine built out of hand-me-down parts, I just hit F12 to pull down Yakuake and type win7.

You must log in to answer this question.

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