18

I need to enable scroll lock so I can toggle lights on my keyboard. This works on Arch.Funny thing it doesn't work on Ubuntu.

http://linuxtechie.wordpress.com/2008/04/07/getting-scroll-lock-to-work-in-ubuntu/

$ xmodmap -e ‘add mod3 = Scroll_Lock’
xmodmap:  unknown command on line commandline:1
xmodmap:  unable to open file 'mod3' for reading
xmodmap:  unable to open file '=' for reading
xmodmap:  unable to open file 'Scroll_Lock’' for reading
xmodmap:  4 errors encountered, aborting.
0

3 Answers 3

28
xmodmap -e 'add mod3 = Scroll_Lock'

(Note the difference in the single-quotes!)

Copy this and paste it in a terminal.

Then the error will no longer occur.

I have used this command successfully on my Ubuntu 12.04 system.

5
  • 2
    This won't work anymore on Gnome 3.10 since it will reset keyboard map after every login and screen lock/unlock Jan 25, 2016 at 20:35
  • How do you do this with just xkb instead of xmodmap? Jan 27, 2016 at 4:52
  • 7
    To any archaeologists: Still works on Ubuntu 16.04
    – foxite
    Mar 3, 2017 at 13:27
  • 1
    Worked on Mint 18!
    – Ronald
    Aug 16, 2017 at 5:33
  • Works great on pure debian (testing, latest stable kernel etc) with K700 keyboard Feb 8, 2021 at 12:24
23

Or you can switch the lights with these:

On:

xset led named "Scroll Lock"

Off:

xset -led named "Scroll Lock"

Works on Ubuntu 12.04 x86 for my SpeedLink illuminated keyboard (SL-6453-SSV-A).

3
  • How can you use setxkbmap to have scroll lock just work?
    – Pykler
    Mar 17, 2015 at 3:58
  • How can you do this automatically when linux boot?
    – Ronald
    Dec 26, 2017 at 23:45
  • Worked like a charm. Thanks. Oct 23, 2021 at 12:31
11

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 dpkg-reconfigure xkb-data
5
  • 1
    Works on ubuntu 14.04 too (tested with Cooler Master Devastator keyboard) Jan 25, 2016 at 20:34
  • ps: you must remove the '<==<< Add this line' part or else you will not have a functional keyboard upon x restart :)
    – Then Enok
    Dec 11, 2016 at 19:03
  • This worked for me on Ubuntu 16.10. Thanks a bunch, it's been driving me nuts for ages!
    – NotKyon
    Feb 4, 2017 at 16:45
  • Works on Ubuntu 16.04 too
    – rneves
    Feb 27, 2018 at 13:58
  • The right place is actually /usr/share/X11/xkb/symbols/pc. If you edit it, you don't need to edit any layouts files.
    – yanychar
    Dec 8, 2020 at 17:34

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