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.
Open a terminal.
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).
Run xmodmap -e 'add mod3 = Scroll_Lock' and the Scroll Lock key should begin working in X.
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:
- 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.
- Create a script in the /usr/local/bin directory called scrlkon.
sudo touch /usr/local/bin/scrlkon
- 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
- Put the following text into the file:
#!/usr/bin/sh
sleep 4
exec xmodmap -e 'add mod3 = Scroll_Lock'
exit
- Save the file and make it executable:
sudo chmod +x /usr/local/bin/scrlkon
- Call the script from a Startup item.
You can name that new startup item whatever you like so long as it calls scrlkon
- 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.