How do you remap a key to the Caps Lock key in Xubuntu?

39,853

Solution 1

Another way:

sudo vi /etc/default/keyboard

then find the line that starts with XKBOPTIONS, and add ctrl:nocaps to make Caps Lock an additional Control key or ctrl:swapcaps to swap Caps Lock and Control.

For example, mine looks like

XKBOPTIONS="lv3:ralt_alt,compose:menu,ctrl:nocaps"

then run

sudo dpkg-reconfigure keyboard-configuration

The reason this way is better is that it will take effect on the virtual consoles (e.g. Ctrl+Alt+F1) as well as in the graphical desktop.

Solution 2

To swap the keys go:

XubuntuSettings ManagerSession and Startup

Then in the Sessions and Startup configurator go

Application Autostart (tab at the top) → Add (bottom button)

Now on the Add Application screen

  • Name: Control and CapsLk swap
  • Description: Swap the two keys
  • Command: /usr/bin/setxkbmap -option "ctrl:swapcaps"

To remap Caps Lock to Control go:

Xubuntu → Settings Manager → Session and Startup

Then in the Sessions and Startup configurator go

Application Autostart (tab at the top) → Add (bottom button)

Now on the Add Application screen

Name: Remap CapsLk to Ctrl
Description: Remap the CapsLk key to Control
Command: /usr/bin/setxkbmap -option "ctrl:nocaps"

Solution 3

For compose instead of caps put compose:caps as the -options parameter.

Solution 4

For Raring (at least):

Start "Keyboard layout" (from dash).

Press "Options..." to reach "Keyboard layout options" menu.

I chose "Ctrl key position" => "Caps lock as Ctrl". Your tastes may differ.

Share:
39,853
Evan Carroll
Author by

Evan Carroll

Consider opposing apartheid in Palestine and signing onto the BDS Movement; #1 User for DBA.SE 2017. Available for contracting: 281.901.0011 PostgreSQL & PostGIS / MySQL / SQL Server JavaScript, Typescript, Rx.js, Node.js, Angular Also: C / Perl / Python / Rust / x86 Assembly

Updated on September 18, 2022

Comments

  • Evan Carroll
    Evan Carroll almost 2 years

    I'm using Xubuntu 12.04. How do I either swap or remap the Control (or any key) and Caps Lock keys?

  • foxxtrot
    foxxtrot almost 12 years
    Wow, that is dramatically harder than it used to be
  • Ehtesh Choudhury
    Ehtesh Choudhury over 10 years
    This is beautiful; how long has XKBOPTIONS been around for?
  • Mikel
    Mikel over 10 years
    XkbOptions is named for a setting in X. The capability is provided by the console-setup package, which seems to have been in Ubuntu since at least Lucid, and probably earlier.
  • Evan Carroll
    Evan Carroll over 10 years
    I like your method, but unfortunately it just isn't working. I even see a new init image generated.
  • Chris
    Chris over 10 years
    On my almost fresh Ubuntu 13.10 install, it works when manually executed but not from “Session and Startup”.
  • Bjarke Freund-Hansen
    Bjarke Freund-Hansen about 10 years
    Works perfectly on xubuntu 14.04, thank you
  • Deepak Verma
    Deepak Verma about 10 years
    What is "dash"? Surely not Unity (in Xubuntu), I hope. This sounds a lot like the Gnome solution that is unavailable in Xubuntu.
  • Doorknob
    Doorknob almost 10 years
    Also works flawlessly here on Ubuntu 14.04.
  • Dror
    Dror almost 10 years
    Is it possible that I have to fire the last command each time I start the desktop (LXDE in my case)?
  • Mikel
    Mikel almost 10 years
    Dror, yes, it's possible on some systems.
  • Harry Moreno
    Harry Moreno over 9 years
    use caps:escape to remap the capslock to esc
  • unhammer
    unhammer about 9 years
    I like that this works in the virtual consoles, but is there a way to make it "persistent" so I don't have to do it on every boot?
  • Mikel
    Mikel about 9 years
    As far as I recall, you also need to ensure you've turned on any "Use system keyboard layout" option, and/or disabled IBus. See e.g. askubuntu.com/a/442415/1951
  • unhammer
    unhammer about 9 years
    I've got Unity for testing some stuff, so can't remove Ibus. It has "use system keyboard layout" set, and I've tried sudo dconf write /desktop/ibus/general/use-system-keyboard-layout true, didn't help. Ended up just making an .Xmodmap.
  • Edward Falk
    Edward Falk about 9 years
    This works for 14.04. I'm appalled that Linux doesn't just have a setting for this in this day an age.
  • typesanitizer
    typesanitizer over 8 years
    Also works for Lubuntu 15.10. A couple of the other answers seem specific to Xubuntu.
  • Forbesmyester
    Forbesmyester almost 8 years
    In additions there's a full list of options stored in ` /usr/share/X11/xkb/rules/xorg.lst` if you're on something like an Ubuntu.
  • Evan Carroll
    Evan Carroll almost 8 years
    I no longer suggest this method use the other answer. askubuntu.com/a/223674/29097
  • Mitar
    Mitar over 6 years
    This seems to work only in the X, but not virtual consoles, tested on Ubuntu 17.10.
  • scientific_explorer
    scientific_explorer over 4 years
    Works in xfce ubuntu 18.04 LTS. Needs a reboot though to take effect.