How do I turn off Caps Lock (the lock, not the key) by command line?How can I disable Caps Lock on text-mode (tty) terminals?How to get caps and num lock lights to show when in consolenot able to boot up with the key lock onRemap Caps Lock key to 'Run Command' (Alt+F2)Caps Lock/ Tab Swap Xmodmap ErrorsHow can I make CAPS LOCK act like the caps lock key on a mac?How do I turn Caps Lock into an extra Control key?How to disable caps lock on bootHow to toggle off Caps Lock by Shift key?Caps lock key doesn't workTurn the Caps Lock LED on, while keep Caps Lock status is offI need to know when the “Caps Lock ” key is turned on/offCaps Lock is turned off when i change the language

Working in the USA for living expenses only; allowed on VWP?

What caused the tendency for conservatives to not support climate change regulations?

What if you don't bring your credit card or debit for incidentals?

The deliberate use of misleading terminology

Are there practical reasons to NOT use a stepper motor with lead screw for the X and or Y axes?

Strange math syntax in old basic listing

Alleged sexist comments charges presented toward me

Is having a hidden directory under /etc safe?

Relativistic resistance transformation

Future enhancements for the finite element method

What does War Machine's "Canopy! Canopy!" line mean in "Avengers: Endgame"?

If a problem only occurs randomly once in every N times on average, how many tests do I have to perform to be certain that it's now fixed?

Why were the Night's Watch required to be celibate?

Applicants clearly not having the skills they advertise

Is the capacitor drawn or wired wrongly?

Pros and cons of writing a book review?

What are the problems in teaching guitar via Skype?

How to write a vulnerable moment without it seeming cliche or mushy?

How can an eldritch abomination hide its true form in public?

Singlequote and backslash

Scarif shield and rebel fighters mystery

Can you please explain this joke: "I'm going bananas is what I tell my bananas before I leave the house"?

Is there a rule that prohibits us from using 2 possessives in a row?

Can The Malloreon be read without first reading The Belgariad?



How do I turn off Caps Lock (the lock, not the key) by command line?


How can I disable Caps Lock on text-mode (tty) terminals?How to get caps and num lock lights to show when in consolenot able to boot up with the key lock onRemap Caps Lock key to 'Run Command' (Alt+F2)Caps Lock/ Tab Swap Xmodmap ErrorsHow can I make CAPS LOCK act like the caps lock key on a mac?How do I turn Caps Lock into an extra Control key?How to disable caps lock on bootHow to toggle off Caps Lock by Shift key?Caps lock key doesn't workTurn the Caps Lock LED on, while keep Caps Lock status is offI need to know when the “Caps Lock ” key is turned on/offCaps Lock is turned off when i change the language






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








86















For some reason my laptop is stuck in Caps Lock. I have the Caps Lock key mapped by xmodmap to hyper_l, so I don't have a caps_lock key to turn it off. Is there a way I can turn it off by command line? It would be nice if I could reset the lock state without resetting my computer, especially for future reference. This has happened before, but I would like to know now how to do it properly this time.










share|improve this question
























  • [echo -e "$(dumpkeys | grep ^keymaps)nkeycode 58 = Escape" | sudo loadkeys][1] [Adding the following line to .profile or .bash_profile should disable caps lock:][2] [xmodmap -e "remove lock = Caps_Lock"][3] [1]: askubuntu.com/questions/43986/… [2]: askubuntu.com/questions/43986/… [3]: askubuntu.com/questions/43986/…

    – One Zero
    Nov 17 '11 at 18:02











  • setxkbmap -option caps:none

    – Pavlos Theodorou
    Feb 1 '17 at 9:56











  • @PavlosTheodorou, that will disable CAPS key, it will not toggle its status as the OP requirement.

    – user.dz
    Feb 1 '17 at 10:02











  • there is a bug there. there is no command currently to do that. you could use setleds +caps or -caps but its not working. the only thing u can do is already answered. you can remap caps

    – Pavlos Theodorou
    Feb 1 '17 at 14:18


















86















For some reason my laptop is stuck in Caps Lock. I have the Caps Lock key mapped by xmodmap to hyper_l, so I don't have a caps_lock key to turn it off. Is there a way I can turn it off by command line? It would be nice if I could reset the lock state without resetting my computer, especially for future reference. This has happened before, but I would like to know now how to do it properly this time.










share|improve this question
























  • [echo -e "$(dumpkeys | grep ^keymaps)nkeycode 58 = Escape" | sudo loadkeys][1] [Adding the following line to .profile or .bash_profile should disable caps lock:][2] [xmodmap -e "remove lock = Caps_Lock"][3] [1]: askubuntu.com/questions/43986/… [2]: askubuntu.com/questions/43986/… [3]: askubuntu.com/questions/43986/…

    – One Zero
    Nov 17 '11 at 18:02











  • setxkbmap -option caps:none

    – Pavlos Theodorou
    Feb 1 '17 at 9:56











  • @PavlosTheodorou, that will disable CAPS key, it will not toggle its status as the OP requirement.

    – user.dz
    Feb 1 '17 at 10:02











  • there is a bug there. there is no command currently to do that. you could use setleds +caps or -caps but its not working. the only thing u can do is already answered. you can remap caps

    – Pavlos Theodorou
    Feb 1 '17 at 14:18














86












86








86


39






For some reason my laptop is stuck in Caps Lock. I have the Caps Lock key mapped by xmodmap to hyper_l, so I don't have a caps_lock key to turn it off. Is there a way I can turn it off by command line? It would be nice if I could reset the lock state without resetting my computer, especially for future reference. This has happened before, but I would like to know now how to do it properly this time.










share|improve this question
















For some reason my laptop is stuck in Caps Lock. I have the Caps Lock key mapped by xmodmap to hyper_l, so I don't have a caps_lock key to turn it off. Is there a way I can turn it off by command line? It would be nice if I could reset the lock state without resetting my computer, especially for future reference. This has happened before, but I would like to know now how to do it properly this time.







command-line xmodmap capslock






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 17 '11 at 18:43







Echogene

















asked Nov 17 '11 at 17:51









EchogeneEchogene

1,13031121




1,13031121












  • [echo -e "$(dumpkeys | grep ^keymaps)nkeycode 58 = Escape" | sudo loadkeys][1] [Adding the following line to .profile or .bash_profile should disable caps lock:][2] [xmodmap -e "remove lock = Caps_Lock"][3] [1]: askubuntu.com/questions/43986/… [2]: askubuntu.com/questions/43986/… [3]: askubuntu.com/questions/43986/…

    – One Zero
    Nov 17 '11 at 18:02











  • setxkbmap -option caps:none

    – Pavlos Theodorou
    Feb 1 '17 at 9:56











  • @PavlosTheodorou, that will disable CAPS key, it will not toggle its status as the OP requirement.

    – user.dz
    Feb 1 '17 at 10:02











  • there is a bug there. there is no command currently to do that. you could use setleds +caps or -caps but its not working. the only thing u can do is already answered. you can remap caps

    – Pavlos Theodorou
    Feb 1 '17 at 14:18


















  • [echo -e "$(dumpkeys | grep ^keymaps)nkeycode 58 = Escape" | sudo loadkeys][1] [Adding the following line to .profile or .bash_profile should disable caps lock:][2] [xmodmap -e "remove lock = Caps_Lock"][3] [1]: askubuntu.com/questions/43986/… [2]: askubuntu.com/questions/43986/… [3]: askubuntu.com/questions/43986/…

    – One Zero
    Nov 17 '11 at 18:02











  • setxkbmap -option caps:none

    – Pavlos Theodorou
    Feb 1 '17 at 9:56











  • @PavlosTheodorou, that will disable CAPS key, it will not toggle its status as the OP requirement.

    – user.dz
    Feb 1 '17 at 10:02











  • there is a bug there. there is no command currently to do that. you could use setleds +caps or -caps but its not working. the only thing u can do is already answered. you can remap caps

    – Pavlos Theodorou
    Feb 1 '17 at 14:18

















[echo -e "$(dumpkeys | grep ^keymaps)nkeycode 58 = Escape" | sudo loadkeys][1] [Adding the following line to .profile or .bash_profile should disable caps lock:][2] [xmodmap -e "remove lock = Caps_Lock"][3] [1]: askubuntu.com/questions/43986/… [2]: askubuntu.com/questions/43986/… [3]: askubuntu.com/questions/43986/…

– One Zero
Nov 17 '11 at 18:02





[echo -e "$(dumpkeys | grep ^keymaps)nkeycode 58 = Escape" | sudo loadkeys][1] [Adding the following line to .profile or .bash_profile should disable caps lock:][2] [xmodmap -e "remove lock = Caps_Lock"][3] [1]: askubuntu.com/questions/43986/… [2]: askubuntu.com/questions/43986/… [3]: askubuntu.com/questions/43986/…

– One Zero
Nov 17 '11 at 18:02













setxkbmap -option caps:none

– Pavlos Theodorou
Feb 1 '17 at 9:56





setxkbmap -option caps:none

– Pavlos Theodorou
Feb 1 '17 at 9:56













@PavlosTheodorou, that will disable CAPS key, it will not toggle its status as the OP requirement.

– user.dz
Feb 1 '17 at 10:02





@PavlosTheodorou, that will disable CAPS key, it will not toggle its status as the OP requirement.

– user.dz
Feb 1 '17 at 10:02













there is a bug there. there is no command currently to do that. you could use setleds +caps or -caps but its not working. the only thing u can do is already answered. you can remap caps

– Pavlos Theodorou
Feb 1 '17 at 14:18






there is a bug there. there is no command currently to do that. you could use setleds +caps or -caps but its not working. the only thing u can do is already answered. you can remap caps

– Pavlos Theodorou
Feb 1 '17 at 14:18











5 Answers
5






active

oldest

votes


















125





+300









I don't know of any command line tool for that in Ubuntu. (For Num Lock, there is numlockx Install numlockx.) Here's a one-liner that you can copy-paste into a terminal window:



python -c 'from ctypes import *; X11 = cdll.LoadLibrary("libX11.so.6"); display = X11.XOpenDisplay(None); X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0)); X11.XCloseDisplay(display)'


Here it is again in a more expanded form. We use the Python ctypes library to call C functions from the X library directly. The function XkbLockModifiers changes the state of the keyboard locks, on the core keyboard (XkbUseCoreKbd = 0x0100), affecting Caps Lock (2), setting it to 0 (off).



#!/usr/bin/env python
from ctypes import *
X11 = cdll.LoadLibrary("libX11.so.6")
display = X11.XOpenDisplay(None)
X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0))
X11.XCloseDisplay(display)


If you have a stuck modifier, change 2 to the mask of the modifiers you want to turn off. The modifiers are 1=Shift, 2=Lock (Caps Lock), 4=Control, 8=Mod1, 16=Mod2, 32=Mod3, 64=Mod4, 128=Mod5. Run xmodmap -pm to see what Mod1 through Mod5 correspond to. For example, to turn off all modifiers, call X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(255), c_uint(0)). To turn on Num Lock which is on Mod2 and at the same time turn off Caps Lock, call X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2 | 16), c_uint(16)).




Here's a C version if you want to make a small binary instead of invoking Python. Compile with gcc -O -Wall -o caps_lock_off caps_lock_off.c -lX11, with the packages build-essentials and libx11-dev installed.



#include <stdio.h>
#include <X11/X.h>
#include <X11/XKBlib.h>
int main()

Display *display = XOpenDisplay(NULL);
if (display == NULL)
fprintf(stderr, "Couldn't open displayn");
return 2;

Bool sent = XkbLockModifiers(display, XkbUseCoreKbd, LockMask, 0);
if (!sent)
fprintf(stderr, "Couldn't send LatchLockStaten");
return 1;

#ifdef REPORT_STATE
XkbStateRec xkb_state;
Status status = XkbGetState(display, XkbUseCoreKbd, &xkb_state);
if (status)
fprintf(stderr, "XkbGetState returned %dn", status);
return 1;

printf("state.group=%02xn", xkb_state.group);
printf("state.locked_group=%02xn", xkb_state.locked_group);
printf("state.base_group=%02xn", xkb_state.base_group);
printf("state.latched_group=%02xn", xkb_state.latched_group);
printf("state.mods=%02xn", xkb_state.mods);
printf("state.base_mods=%02xn", xkb_state.base_mods);
printf("state.latched_mods=%02xn", xkb_state.latched_mods);
printf("state.locked_mods=%02xn", xkb_state.locked_mods);
printf("state.compat_state=%02xn", xkb_state.compat_state);
printf("state.grab_mods=%02xn", xkb_state.grab_mods);
printf("state.compat_grab_mods=%02xn", xkb_state.compat_grab_mods);
printf("state.lookup_mods=%02xn", xkb_state.lookup_mods);
printf("state.compat_lookup_mods=%02xn", xkb_state.compat_lookup_mods);
printf("state.ptr_buttons=%02xn", xkb_state.ptr_buttons);
#endif
int err = XCloseDisplay(display);
if (err)
fprintf(stderr, "XCloseDisplay returned %dn", err);
return 1;

return 0;




Also possibly of interest is a way to temporarily ignore Caps Lock:



xkbset nullify lock


After this, Caps Lock will effectively be permanently off, until you reenable it with xkbset nullify -lock.






share|improve this answer

























  • I'll have a go when I'm next on my laptop. I'm on my desktop for now.

    – Echogene
    Nov 17 '11 at 23:50











  • Hmm, the python method used to work for me, but after upgrading to Yakkety it does not. The bug where caps lock gets stuck persists of course!

    – Gringo Suave
    Nov 4 '16 at 20:09











  • @GringoSuave I have no idea why that could be. Please install xtrace and run xtrace python -c 'from ctypes import *; X11 = cdll.LoadLibrary("libX11.so.6"); buf = (c_char*16)(); display = X11.XOpenDisplay(None); X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0)); X11.XkbGetState(display, 0x0100, buf); X11.XCloseDisplay(display)' and post the last few lines, starting with the one containing QueryExtension name='XKEYBOARD'. I don't claim that I'll understand the output but I'll try.

    – Gilles
    Nov 4 '16 at 20:33






  • 1





    I get a segfault: terminated by signal SIGSEGV (Address boundary error) Segmentation fault…

    – Gringo Suave
    Nov 5 '16 at 5:19











  • 000:<:0005: 20: Request(98): QueryExtension name='XKEYBOARD' 000:>:0005:32: Reply to QueryExtension: present=true(0x01) major-opcode=135 first-event=85 first-error=137 000:<:0006: 8: XKEYBOARD-Request(135,0): UseExtension major=1 minor=0 000:>:0006:32: Reply to UseExtension: major=1 minor=0

    – Gringo Suave
    Nov 5 '16 at 5:20


















51














X automation tools could be used for sending the required key events.




Note:

This solution needs you to tape the correct password, if your
CAPS is currently active: open office writer, write password there,
change the letter case, copy it, then paste it to password dialog.



If that previous step is not possible or doesn't work, Go with Gilles' answer / python script. It does not need to install any additional tool, it uses only python & libX11 shared lib which are pre-installed.




Using xdotool




  1. Install it



    sudo apt-get install xdotool



  2. Send a CAPS down/up event



    xdotool key Caps_Lock


Another tool is xte




  1. Install it



    sudo apt-get install xautomation



  2. Send a CAPS lock down/up event



    xte "key Caps_Lock"


References:



  • Ubuntu Forums: Caps lock inverted

  • man xdotool

  • man xte





share|improve this answer

























  • What if this doesn't work?

    – quant_dev
    Jun 16 '15 at 16:24






  • 2





    This is the only one that worked for me. nullify and others didn't work.

    – lnostdal
    Jul 8 '15 at 10:15






  • 10





    CAN'T INSTALL, PASSWORD NOT ACCEPTED. :(

    – Gringo Suave
    Dec 19 '15 at 1:22






  • 1





    You can use Shift keys for inputting lowercase letters while Caps Lock is enabled.

    – chris544
    Feb 24 '18 at 21:43






  • 1





    If you use an external keyboard another option could be re-plugging it; Caps Lock modifier might get reset, so you can input lowercase letters.

    – chris544
    Feb 24 '18 at 21:54


















10














As for Gilles python version not working in newer ubuntus, setting the correct return for the open display seems to do the trick:



#! /usr/bin/env python

from ctypes import *
import subprocess

class Display(Structure):
""" opaque struct """

X11 = cdll.LoadLibrary("libX11.so.6")
X11.XOpenDisplay.restype = POINTER(Display)

display = X11.XOpenDisplay(c_int(0))
X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0))
X11.XCloseDisplay(display)


(Code adapted from https://stackoverflow.com/questions/29638210/how-can-i-use-python-xlib-to-generate-a-single-keypress)






share|improve this answer

























  • This works really well, is a life saviour

    – Garret Gang
    Apr 20 at 18:48


















7














If you can't access CAPS because you remapped it in .bashrc, like I did, then simply switching to a virtual terminal (alt+ctl+fN) and then switching back worked for me.






share|improve this answer


















  • 1





    Switching didn't quite do it, but it did get me to a point where I could press caps lock to get thing right.

    – labyrinth
    Feb 16 '18 at 13:33


















1














I had this problem and was able to fix it by using the OnBoard keyboard (in Ubuntu Mate, under Universal Access).



Once turned on you should see the CapsLock key is red, or somehow indicated that it is locked on. Then you can press to toggle off.






share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f80254%2fhow-do-i-turn-off-caps-lock-the-lock-not-the-key-by-command-line%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    5 Answers
    5






    active

    oldest

    votes








    5 Answers
    5






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    125





    +300









    I don't know of any command line tool for that in Ubuntu. (For Num Lock, there is numlockx Install numlockx.) Here's a one-liner that you can copy-paste into a terminal window:



    python -c 'from ctypes import *; X11 = cdll.LoadLibrary("libX11.so.6"); display = X11.XOpenDisplay(None); X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0)); X11.XCloseDisplay(display)'


    Here it is again in a more expanded form. We use the Python ctypes library to call C functions from the X library directly. The function XkbLockModifiers changes the state of the keyboard locks, on the core keyboard (XkbUseCoreKbd = 0x0100), affecting Caps Lock (2), setting it to 0 (off).



    #!/usr/bin/env python
    from ctypes import *
    X11 = cdll.LoadLibrary("libX11.so.6")
    display = X11.XOpenDisplay(None)
    X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0))
    X11.XCloseDisplay(display)


    If you have a stuck modifier, change 2 to the mask of the modifiers you want to turn off. The modifiers are 1=Shift, 2=Lock (Caps Lock), 4=Control, 8=Mod1, 16=Mod2, 32=Mod3, 64=Mod4, 128=Mod5. Run xmodmap -pm to see what Mod1 through Mod5 correspond to. For example, to turn off all modifiers, call X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(255), c_uint(0)). To turn on Num Lock which is on Mod2 and at the same time turn off Caps Lock, call X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2 | 16), c_uint(16)).




    Here's a C version if you want to make a small binary instead of invoking Python. Compile with gcc -O -Wall -o caps_lock_off caps_lock_off.c -lX11, with the packages build-essentials and libx11-dev installed.



    #include <stdio.h>
    #include <X11/X.h>
    #include <X11/XKBlib.h>
    int main()

    Display *display = XOpenDisplay(NULL);
    if (display == NULL)
    fprintf(stderr, "Couldn't open displayn");
    return 2;

    Bool sent = XkbLockModifiers(display, XkbUseCoreKbd, LockMask, 0);
    if (!sent)
    fprintf(stderr, "Couldn't send LatchLockStaten");
    return 1;

    #ifdef REPORT_STATE
    XkbStateRec xkb_state;
    Status status = XkbGetState(display, XkbUseCoreKbd, &xkb_state);
    if (status)
    fprintf(stderr, "XkbGetState returned %dn", status);
    return 1;

    printf("state.group=%02xn", xkb_state.group);
    printf("state.locked_group=%02xn", xkb_state.locked_group);
    printf("state.base_group=%02xn", xkb_state.base_group);
    printf("state.latched_group=%02xn", xkb_state.latched_group);
    printf("state.mods=%02xn", xkb_state.mods);
    printf("state.base_mods=%02xn", xkb_state.base_mods);
    printf("state.latched_mods=%02xn", xkb_state.latched_mods);
    printf("state.locked_mods=%02xn", xkb_state.locked_mods);
    printf("state.compat_state=%02xn", xkb_state.compat_state);
    printf("state.grab_mods=%02xn", xkb_state.grab_mods);
    printf("state.compat_grab_mods=%02xn", xkb_state.compat_grab_mods);
    printf("state.lookup_mods=%02xn", xkb_state.lookup_mods);
    printf("state.compat_lookup_mods=%02xn", xkb_state.compat_lookup_mods);
    printf("state.ptr_buttons=%02xn", xkb_state.ptr_buttons);
    #endif
    int err = XCloseDisplay(display);
    if (err)
    fprintf(stderr, "XCloseDisplay returned %dn", err);
    return 1;

    return 0;




    Also possibly of interest is a way to temporarily ignore Caps Lock:



    xkbset nullify lock


    After this, Caps Lock will effectively be permanently off, until you reenable it with xkbset nullify -lock.






    share|improve this answer

























    • I'll have a go when I'm next on my laptop. I'm on my desktop for now.

      – Echogene
      Nov 17 '11 at 23:50











    • Hmm, the python method used to work for me, but after upgrading to Yakkety it does not. The bug where caps lock gets stuck persists of course!

      – Gringo Suave
      Nov 4 '16 at 20:09











    • @GringoSuave I have no idea why that could be. Please install xtrace and run xtrace python -c 'from ctypes import *; X11 = cdll.LoadLibrary("libX11.so.6"); buf = (c_char*16)(); display = X11.XOpenDisplay(None); X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0)); X11.XkbGetState(display, 0x0100, buf); X11.XCloseDisplay(display)' and post the last few lines, starting with the one containing QueryExtension name='XKEYBOARD'. I don't claim that I'll understand the output but I'll try.

      – Gilles
      Nov 4 '16 at 20:33






    • 1





      I get a segfault: terminated by signal SIGSEGV (Address boundary error) Segmentation fault…

      – Gringo Suave
      Nov 5 '16 at 5:19











    • 000:<:0005: 20: Request(98): QueryExtension name='XKEYBOARD' 000:>:0005:32: Reply to QueryExtension: present=true(0x01) major-opcode=135 first-event=85 first-error=137 000:<:0006: 8: XKEYBOARD-Request(135,0): UseExtension major=1 minor=0 000:>:0006:32: Reply to UseExtension: major=1 minor=0

      – Gringo Suave
      Nov 5 '16 at 5:20















    125





    +300









    I don't know of any command line tool for that in Ubuntu. (For Num Lock, there is numlockx Install numlockx.) Here's a one-liner that you can copy-paste into a terminal window:



    python -c 'from ctypes import *; X11 = cdll.LoadLibrary("libX11.so.6"); display = X11.XOpenDisplay(None); X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0)); X11.XCloseDisplay(display)'


    Here it is again in a more expanded form. We use the Python ctypes library to call C functions from the X library directly. The function XkbLockModifiers changes the state of the keyboard locks, on the core keyboard (XkbUseCoreKbd = 0x0100), affecting Caps Lock (2), setting it to 0 (off).



    #!/usr/bin/env python
    from ctypes import *
    X11 = cdll.LoadLibrary("libX11.so.6")
    display = X11.XOpenDisplay(None)
    X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0))
    X11.XCloseDisplay(display)


    If you have a stuck modifier, change 2 to the mask of the modifiers you want to turn off. The modifiers are 1=Shift, 2=Lock (Caps Lock), 4=Control, 8=Mod1, 16=Mod2, 32=Mod3, 64=Mod4, 128=Mod5. Run xmodmap -pm to see what Mod1 through Mod5 correspond to. For example, to turn off all modifiers, call X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(255), c_uint(0)). To turn on Num Lock which is on Mod2 and at the same time turn off Caps Lock, call X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2 | 16), c_uint(16)).




    Here's a C version if you want to make a small binary instead of invoking Python. Compile with gcc -O -Wall -o caps_lock_off caps_lock_off.c -lX11, with the packages build-essentials and libx11-dev installed.



    #include <stdio.h>
    #include <X11/X.h>
    #include <X11/XKBlib.h>
    int main()

    Display *display = XOpenDisplay(NULL);
    if (display == NULL)
    fprintf(stderr, "Couldn't open displayn");
    return 2;

    Bool sent = XkbLockModifiers(display, XkbUseCoreKbd, LockMask, 0);
    if (!sent)
    fprintf(stderr, "Couldn't send LatchLockStaten");
    return 1;

    #ifdef REPORT_STATE
    XkbStateRec xkb_state;
    Status status = XkbGetState(display, XkbUseCoreKbd, &xkb_state);
    if (status)
    fprintf(stderr, "XkbGetState returned %dn", status);
    return 1;

    printf("state.group=%02xn", xkb_state.group);
    printf("state.locked_group=%02xn", xkb_state.locked_group);
    printf("state.base_group=%02xn", xkb_state.base_group);
    printf("state.latched_group=%02xn", xkb_state.latched_group);
    printf("state.mods=%02xn", xkb_state.mods);
    printf("state.base_mods=%02xn", xkb_state.base_mods);
    printf("state.latched_mods=%02xn", xkb_state.latched_mods);
    printf("state.locked_mods=%02xn", xkb_state.locked_mods);
    printf("state.compat_state=%02xn", xkb_state.compat_state);
    printf("state.grab_mods=%02xn", xkb_state.grab_mods);
    printf("state.compat_grab_mods=%02xn", xkb_state.compat_grab_mods);
    printf("state.lookup_mods=%02xn", xkb_state.lookup_mods);
    printf("state.compat_lookup_mods=%02xn", xkb_state.compat_lookup_mods);
    printf("state.ptr_buttons=%02xn", xkb_state.ptr_buttons);
    #endif
    int err = XCloseDisplay(display);
    if (err)
    fprintf(stderr, "XCloseDisplay returned %dn", err);
    return 1;

    return 0;




    Also possibly of interest is a way to temporarily ignore Caps Lock:



    xkbset nullify lock


    After this, Caps Lock will effectively be permanently off, until you reenable it with xkbset nullify -lock.






    share|improve this answer

























    • I'll have a go when I'm next on my laptop. I'm on my desktop for now.

      – Echogene
      Nov 17 '11 at 23:50











    • Hmm, the python method used to work for me, but after upgrading to Yakkety it does not. The bug where caps lock gets stuck persists of course!

      – Gringo Suave
      Nov 4 '16 at 20:09











    • @GringoSuave I have no idea why that could be. Please install xtrace and run xtrace python -c 'from ctypes import *; X11 = cdll.LoadLibrary("libX11.so.6"); buf = (c_char*16)(); display = X11.XOpenDisplay(None); X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0)); X11.XkbGetState(display, 0x0100, buf); X11.XCloseDisplay(display)' and post the last few lines, starting with the one containing QueryExtension name='XKEYBOARD'. I don't claim that I'll understand the output but I'll try.

      – Gilles
      Nov 4 '16 at 20:33






    • 1





      I get a segfault: terminated by signal SIGSEGV (Address boundary error) Segmentation fault…

      – Gringo Suave
      Nov 5 '16 at 5:19











    • 000:<:0005: 20: Request(98): QueryExtension name='XKEYBOARD' 000:>:0005:32: Reply to QueryExtension: present=true(0x01) major-opcode=135 first-event=85 first-error=137 000:<:0006: 8: XKEYBOARD-Request(135,0): UseExtension major=1 minor=0 000:>:0006:32: Reply to UseExtension: major=1 minor=0

      – Gringo Suave
      Nov 5 '16 at 5:20













    125





    +300







    125





    +300



    125




    +300





    I don't know of any command line tool for that in Ubuntu. (For Num Lock, there is numlockx Install numlockx.) Here's a one-liner that you can copy-paste into a terminal window:



    python -c 'from ctypes import *; X11 = cdll.LoadLibrary("libX11.so.6"); display = X11.XOpenDisplay(None); X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0)); X11.XCloseDisplay(display)'


    Here it is again in a more expanded form. We use the Python ctypes library to call C functions from the X library directly. The function XkbLockModifiers changes the state of the keyboard locks, on the core keyboard (XkbUseCoreKbd = 0x0100), affecting Caps Lock (2), setting it to 0 (off).



    #!/usr/bin/env python
    from ctypes import *
    X11 = cdll.LoadLibrary("libX11.so.6")
    display = X11.XOpenDisplay(None)
    X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0))
    X11.XCloseDisplay(display)


    If you have a stuck modifier, change 2 to the mask of the modifiers you want to turn off. The modifiers are 1=Shift, 2=Lock (Caps Lock), 4=Control, 8=Mod1, 16=Mod2, 32=Mod3, 64=Mod4, 128=Mod5. Run xmodmap -pm to see what Mod1 through Mod5 correspond to. For example, to turn off all modifiers, call X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(255), c_uint(0)). To turn on Num Lock which is on Mod2 and at the same time turn off Caps Lock, call X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2 | 16), c_uint(16)).




    Here's a C version if you want to make a small binary instead of invoking Python. Compile with gcc -O -Wall -o caps_lock_off caps_lock_off.c -lX11, with the packages build-essentials and libx11-dev installed.



    #include <stdio.h>
    #include <X11/X.h>
    #include <X11/XKBlib.h>
    int main()

    Display *display = XOpenDisplay(NULL);
    if (display == NULL)
    fprintf(stderr, "Couldn't open displayn");
    return 2;

    Bool sent = XkbLockModifiers(display, XkbUseCoreKbd, LockMask, 0);
    if (!sent)
    fprintf(stderr, "Couldn't send LatchLockStaten");
    return 1;

    #ifdef REPORT_STATE
    XkbStateRec xkb_state;
    Status status = XkbGetState(display, XkbUseCoreKbd, &xkb_state);
    if (status)
    fprintf(stderr, "XkbGetState returned %dn", status);
    return 1;

    printf("state.group=%02xn", xkb_state.group);
    printf("state.locked_group=%02xn", xkb_state.locked_group);
    printf("state.base_group=%02xn", xkb_state.base_group);
    printf("state.latched_group=%02xn", xkb_state.latched_group);
    printf("state.mods=%02xn", xkb_state.mods);
    printf("state.base_mods=%02xn", xkb_state.base_mods);
    printf("state.latched_mods=%02xn", xkb_state.latched_mods);
    printf("state.locked_mods=%02xn", xkb_state.locked_mods);
    printf("state.compat_state=%02xn", xkb_state.compat_state);
    printf("state.grab_mods=%02xn", xkb_state.grab_mods);
    printf("state.compat_grab_mods=%02xn", xkb_state.compat_grab_mods);
    printf("state.lookup_mods=%02xn", xkb_state.lookup_mods);
    printf("state.compat_lookup_mods=%02xn", xkb_state.compat_lookup_mods);
    printf("state.ptr_buttons=%02xn", xkb_state.ptr_buttons);
    #endif
    int err = XCloseDisplay(display);
    if (err)
    fprintf(stderr, "XCloseDisplay returned %dn", err);
    return 1;

    return 0;




    Also possibly of interest is a way to temporarily ignore Caps Lock:



    xkbset nullify lock


    After this, Caps Lock will effectively be permanently off, until you reenable it with xkbset nullify -lock.






    share|improve this answer















    I don't know of any command line tool for that in Ubuntu. (For Num Lock, there is numlockx Install numlockx.) Here's a one-liner that you can copy-paste into a terminal window:



    python -c 'from ctypes import *; X11 = cdll.LoadLibrary("libX11.so.6"); display = X11.XOpenDisplay(None); X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0)); X11.XCloseDisplay(display)'


    Here it is again in a more expanded form. We use the Python ctypes library to call C functions from the X library directly. The function XkbLockModifiers changes the state of the keyboard locks, on the core keyboard (XkbUseCoreKbd = 0x0100), affecting Caps Lock (2), setting it to 0 (off).



    #!/usr/bin/env python
    from ctypes import *
    X11 = cdll.LoadLibrary("libX11.so.6")
    display = X11.XOpenDisplay(None)
    X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0))
    X11.XCloseDisplay(display)


    If you have a stuck modifier, change 2 to the mask of the modifiers you want to turn off. The modifiers are 1=Shift, 2=Lock (Caps Lock), 4=Control, 8=Mod1, 16=Mod2, 32=Mod3, 64=Mod4, 128=Mod5. Run xmodmap -pm to see what Mod1 through Mod5 correspond to. For example, to turn off all modifiers, call X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(255), c_uint(0)). To turn on Num Lock which is on Mod2 and at the same time turn off Caps Lock, call X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2 | 16), c_uint(16)).




    Here's a C version if you want to make a small binary instead of invoking Python. Compile with gcc -O -Wall -o caps_lock_off caps_lock_off.c -lX11, with the packages build-essentials and libx11-dev installed.



    #include <stdio.h>
    #include <X11/X.h>
    #include <X11/XKBlib.h>
    int main()

    Display *display = XOpenDisplay(NULL);
    if (display == NULL)
    fprintf(stderr, "Couldn't open displayn");
    return 2;

    Bool sent = XkbLockModifiers(display, XkbUseCoreKbd, LockMask, 0);
    if (!sent)
    fprintf(stderr, "Couldn't send LatchLockStaten");
    return 1;

    #ifdef REPORT_STATE
    XkbStateRec xkb_state;
    Status status = XkbGetState(display, XkbUseCoreKbd, &xkb_state);
    if (status)
    fprintf(stderr, "XkbGetState returned %dn", status);
    return 1;

    printf("state.group=%02xn", xkb_state.group);
    printf("state.locked_group=%02xn", xkb_state.locked_group);
    printf("state.base_group=%02xn", xkb_state.base_group);
    printf("state.latched_group=%02xn", xkb_state.latched_group);
    printf("state.mods=%02xn", xkb_state.mods);
    printf("state.base_mods=%02xn", xkb_state.base_mods);
    printf("state.latched_mods=%02xn", xkb_state.latched_mods);
    printf("state.locked_mods=%02xn", xkb_state.locked_mods);
    printf("state.compat_state=%02xn", xkb_state.compat_state);
    printf("state.grab_mods=%02xn", xkb_state.grab_mods);
    printf("state.compat_grab_mods=%02xn", xkb_state.compat_grab_mods);
    printf("state.lookup_mods=%02xn", xkb_state.lookup_mods);
    printf("state.compat_lookup_mods=%02xn", xkb_state.compat_lookup_mods);
    printf("state.ptr_buttons=%02xn", xkb_state.ptr_buttons);
    #endif
    int err = XCloseDisplay(display);
    if (err)
    fprintf(stderr, "XCloseDisplay returned %dn", err);
    return 1;

    return 0;




    Also possibly of interest is a way to temporarily ignore Caps Lock:



    xkbset nullify lock


    After this, Caps Lock will effectively be permanently off, until you reenable it with xkbset nullify -lock.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 11 '17 at 19:00









    Community

    1




    1










    answered Nov 17 '11 at 22:26









    GillesGilles

    46.1k13103143




    46.1k13103143












    • I'll have a go when I'm next on my laptop. I'm on my desktop for now.

      – Echogene
      Nov 17 '11 at 23:50











    • Hmm, the python method used to work for me, but after upgrading to Yakkety it does not. The bug where caps lock gets stuck persists of course!

      – Gringo Suave
      Nov 4 '16 at 20:09











    • @GringoSuave I have no idea why that could be. Please install xtrace and run xtrace python -c 'from ctypes import *; X11 = cdll.LoadLibrary("libX11.so.6"); buf = (c_char*16)(); display = X11.XOpenDisplay(None); X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0)); X11.XkbGetState(display, 0x0100, buf); X11.XCloseDisplay(display)' and post the last few lines, starting with the one containing QueryExtension name='XKEYBOARD'. I don't claim that I'll understand the output but I'll try.

      – Gilles
      Nov 4 '16 at 20:33






    • 1





      I get a segfault: terminated by signal SIGSEGV (Address boundary error) Segmentation fault…

      – Gringo Suave
      Nov 5 '16 at 5:19











    • 000:<:0005: 20: Request(98): QueryExtension name='XKEYBOARD' 000:>:0005:32: Reply to QueryExtension: present=true(0x01) major-opcode=135 first-event=85 first-error=137 000:<:0006: 8: XKEYBOARD-Request(135,0): UseExtension major=1 minor=0 000:>:0006:32: Reply to UseExtension: major=1 minor=0

      – Gringo Suave
      Nov 5 '16 at 5:20

















    • I'll have a go when I'm next on my laptop. I'm on my desktop for now.

      – Echogene
      Nov 17 '11 at 23:50











    • Hmm, the python method used to work for me, but after upgrading to Yakkety it does not. The bug where caps lock gets stuck persists of course!

      – Gringo Suave
      Nov 4 '16 at 20:09











    • @GringoSuave I have no idea why that could be. Please install xtrace and run xtrace python -c 'from ctypes import *; X11 = cdll.LoadLibrary("libX11.so.6"); buf = (c_char*16)(); display = X11.XOpenDisplay(None); X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0)); X11.XkbGetState(display, 0x0100, buf); X11.XCloseDisplay(display)' and post the last few lines, starting with the one containing QueryExtension name='XKEYBOARD'. I don't claim that I'll understand the output but I'll try.

      – Gilles
      Nov 4 '16 at 20:33






    • 1





      I get a segfault: terminated by signal SIGSEGV (Address boundary error) Segmentation fault…

      – Gringo Suave
      Nov 5 '16 at 5:19











    • 000:<:0005: 20: Request(98): QueryExtension name='XKEYBOARD' 000:>:0005:32: Reply to QueryExtension: present=true(0x01) major-opcode=135 first-event=85 first-error=137 000:<:0006: 8: XKEYBOARD-Request(135,0): UseExtension major=1 minor=0 000:>:0006:32: Reply to UseExtension: major=1 minor=0

      – Gringo Suave
      Nov 5 '16 at 5:20
















    I'll have a go when I'm next on my laptop. I'm on my desktop for now.

    – Echogene
    Nov 17 '11 at 23:50





    I'll have a go when I'm next on my laptop. I'm on my desktop for now.

    – Echogene
    Nov 17 '11 at 23:50













    Hmm, the python method used to work for me, but after upgrading to Yakkety it does not. The bug where caps lock gets stuck persists of course!

    – Gringo Suave
    Nov 4 '16 at 20:09





    Hmm, the python method used to work for me, but after upgrading to Yakkety it does not. The bug where caps lock gets stuck persists of course!

    – Gringo Suave
    Nov 4 '16 at 20:09













    @GringoSuave I have no idea why that could be. Please install xtrace and run xtrace python -c 'from ctypes import *; X11 = cdll.LoadLibrary("libX11.so.6"); buf = (c_char*16)(); display = X11.XOpenDisplay(None); X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0)); X11.XkbGetState(display, 0x0100, buf); X11.XCloseDisplay(display)' and post the last few lines, starting with the one containing QueryExtension name='XKEYBOARD'. I don't claim that I'll understand the output but I'll try.

    – Gilles
    Nov 4 '16 at 20:33





    @GringoSuave I have no idea why that could be. Please install xtrace and run xtrace python -c 'from ctypes import *; X11 = cdll.LoadLibrary("libX11.so.6"); buf = (c_char*16)(); display = X11.XOpenDisplay(None); X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0)); X11.XkbGetState(display, 0x0100, buf); X11.XCloseDisplay(display)' and post the last few lines, starting with the one containing QueryExtension name='XKEYBOARD'. I don't claim that I'll understand the output but I'll try.

    – Gilles
    Nov 4 '16 at 20:33




    1




    1





    I get a segfault: terminated by signal SIGSEGV (Address boundary error) Segmentation fault…

    – Gringo Suave
    Nov 5 '16 at 5:19





    I get a segfault: terminated by signal SIGSEGV (Address boundary error) Segmentation fault…

    – Gringo Suave
    Nov 5 '16 at 5:19













    000:<:0005: 20: Request(98): QueryExtension name='XKEYBOARD' 000:>:0005:32: Reply to QueryExtension: present=true(0x01) major-opcode=135 first-event=85 first-error=137 000:<:0006: 8: XKEYBOARD-Request(135,0): UseExtension major=1 minor=0 000:>:0006:32: Reply to UseExtension: major=1 minor=0

    – Gringo Suave
    Nov 5 '16 at 5:20





    000:<:0005: 20: Request(98): QueryExtension name='XKEYBOARD' 000:>:0005:32: Reply to QueryExtension: present=true(0x01) major-opcode=135 first-event=85 first-error=137 000:<:0006: 8: XKEYBOARD-Request(135,0): UseExtension major=1 minor=0 000:>:0006:32: Reply to UseExtension: major=1 minor=0

    – Gringo Suave
    Nov 5 '16 at 5:20













    51














    X automation tools could be used for sending the required key events.




    Note:

    This solution needs you to tape the correct password, if your
    CAPS is currently active: open office writer, write password there,
    change the letter case, copy it, then paste it to password dialog.



    If that previous step is not possible or doesn't work, Go with Gilles' answer / python script. It does not need to install any additional tool, it uses only python & libX11 shared lib which are pre-installed.




    Using xdotool




    1. Install it



      sudo apt-get install xdotool



    2. Send a CAPS down/up event



      xdotool key Caps_Lock


    Another tool is xte




    1. Install it



      sudo apt-get install xautomation



    2. Send a CAPS lock down/up event



      xte "key Caps_Lock"


    References:



    • Ubuntu Forums: Caps lock inverted

    • man xdotool

    • man xte





    share|improve this answer

























    • What if this doesn't work?

      – quant_dev
      Jun 16 '15 at 16:24






    • 2





      This is the only one that worked for me. nullify and others didn't work.

      – lnostdal
      Jul 8 '15 at 10:15






    • 10





      CAN'T INSTALL, PASSWORD NOT ACCEPTED. :(

      – Gringo Suave
      Dec 19 '15 at 1:22






    • 1





      You can use Shift keys for inputting lowercase letters while Caps Lock is enabled.

      – chris544
      Feb 24 '18 at 21:43






    • 1





      If you use an external keyboard another option could be re-plugging it; Caps Lock modifier might get reset, so you can input lowercase letters.

      – chris544
      Feb 24 '18 at 21:54















    51














    X automation tools could be used for sending the required key events.




    Note:

    This solution needs you to tape the correct password, if your
    CAPS is currently active: open office writer, write password there,
    change the letter case, copy it, then paste it to password dialog.



    If that previous step is not possible or doesn't work, Go with Gilles' answer / python script. It does not need to install any additional tool, it uses only python & libX11 shared lib which are pre-installed.




    Using xdotool




    1. Install it



      sudo apt-get install xdotool



    2. Send a CAPS down/up event



      xdotool key Caps_Lock


    Another tool is xte




    1. Install it



      sudo apt-get install xautomation



    2. Send a CAPS lock down/up event



      xte "key Caps_Lock"


    References:



    • Ubuntu Forums: Caps lock inverted

    • man xdotool

    • man xte





    share|improve this answer

























    • What if this doesn't work?

      – quant_dev
      Jun 16 '15 at 16:24






    • 2





      This is the only one that worked for me. nullify and others didn't work.

      – lnostdal
      Jul 8 '15 at 10:15






    • 10





      CAN'T INSTALL, PASSWORD NOT ACCEPTED. :(

      – Gringo Suave
      Dec 19 '15 at 1:22






    • 1





      You can use Shift keys for inputting lowercase letters while Caps Lock is enabled.

      – chris544
      Feb 24 '18 at 21:43






    • 1





      If you use an external keyboard another option could be re-plugging it; Caps Lock modifier might get reset, so you can input lowercase letters.

      – chris544
      Feb 24 '18 at 21:54













    51












    51








    51







    X automation tools could be used for sending the required key events.




    Note:

    This solution needs you to tape the correct password, if your
    CAPS is currently active: open office writer, write password there,
    change the letter case, copy it, then paste it to password dialog.



    If that previous step is not possible or doesn't work, Go with Gilles' answer / python script. It does not need to install any additional tool, it uses only python & libX11 shared lib which are pre-installed.




    Using xdotool




    1. Install it



      sudo apt-get install xdotool



    2. Send a CAPS down/up event



      xdotool key Caps_Lock


    Another tool is xte




    1. Install it



      sudo apt-get install xautomation



    2. Send a CAPS lock down/up event



      xte "key Caps_Lock"


    References:



    • Ubuntu Forums: Caps lock inverted

    • man xdotool

    • man xte





    share|improve this answer















    X automation tools could be used for sending the required key events.




    Note:

    This solution needs you to tape the correct password, if your
    CAPS is currently active: open office writer, write password there,
    change the letter case, copy it, then paste it to password dialog.



    If that previous step is not possible or doesn't work, Go with Gilles' answer / python script. It does not need to install any additional tool, it uses only python & libX11 shared lib which are pre-installed.




    Using xdotool




    1. Install it



      sudo apt-get install xdotool



    2. Send a CAPS down/up event



      xdotool key Caps_Lock


    Another tool is xte




    1. Install it



      sudo apt-get install xautomation



    2. Send a CAPS lock down/up event



      xte "key Caps_Lock"


    References:



    • Ubuntu Forums: Caps lock inverted

    • man xdotool

    • man xte






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Feb 1 '17 at 9:45

























    answered Apr 11 '15 at 8:41









    user.dzuser.dz

    35.5k11101182




    35.5k11101182












    • What if this doesn't work?

      – quant_dev
      Jun 16 '15 at 16:24






    • 2





      This is the only one that worked for me. nullify and others didn't work.

      – lnostdal
      Jul 8 '15 at 10:15






    • 10





      CAN'T INSTALL, PASSWORD NOT ACCEPTED. :(

      – Gringo Suave
      Dec 19 '15 at 1:22






    • 1





      You can use Shift keys for inputting lowercase letters while Caps Lock is enabled.

      – chris544
      Feb 24 '18 at 21:43






    • 1





      If you use an external keyboard another option could be re-plugging it; Caps Lock modifier might get reset, so you can input lowercase letters.

      – chris544
      Feb 24 '18 at 21:54

















    • What if this doesn't work?

      – quant_dev
      Jun 16 '15 at 16:24






    • 2





      This is the only one that worked for me. nullify and others didn't work.

      – lnostdal
      Jul 8 '15 at 10:15






    • 10





      CAN'T INSTALL, PASSWORD NOT ACCEPTED. :(

      – Gringo Suave
      Dec 19 '15 at 1:22






    • 1





      You can use Shift keys for inputting lowercase letters while Caps Lock is enabled.

      – chris544
      Feb 24 '18 at 21:43






    • 1





      If you use an external keyboard another option could be re-plugging it; Caps Lock modifier might get reset, so you can input lowercase letters.

      – chris544
      Feb 24 '18 at 21:54
















    What if this doesn't work?

    – quant_dev
    Jun 16 '15 at 16:24





    What if this doesn't work?

    – quant_dev
    Jun 16 '15 at 16:24




    2




    2





    This is the only one that worked for me. nullify and others didn't work.

    – lnostdal
    Jul 8 '15 at 10:15





    This is the only one that worked for me. nullify and others didn't work.

    – lnostdal
    Jul 8 '15 at 10:15




    10




    10





    CAN'T INSTALL, PASSWORD NOT ACCEPTED. :(

    – Gringo Suave
    Dec 19 '15 at 1:22





    CAN'T INSTALL, PASSWORD NOT ACCEPTED. :(

    – Gringo Suave
    Dec 19 '15 at 1:22




    1




    1





    You can use Shift keys for inputting lowercase letters while Caps Lock is enabled.

    – chris544
    Feb 24 '18 at 21:43





    You can use Shift keys for inputting lowercase letters while Caps Lock is enabled.

    – chris544
    Feb 24 '18 at 21:43




    1




    1





    If you use an external keyboard another option could be re-plugging it; Caps Lock modifier might get reset, so you can input lowercase letters.

    – chris544
    Feb 24 '18 at 21:54





    If you use an external keyboard another option could be re-plugging it; Caps Lock modifier might get reset, so you can input lowercase letters.

    – chris544
    Feb 24 '18 at 21:54











    10














    As for Gilles python version not working in newer ubuntus, setting the correct return for the open display seems to do the trick:



    #! /usr/bin/env python

    from ctypes import *
    import subprocess

    class Display(Structure):
    """ opaque struct """

    X11 = cdll.LoadLibrary("libX11.so.6")
    X11.XOpenDisplay.restype = POINTER(Display)

    display = X11.XOpenDisplay(c_int(0))
    X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0))
    X11.XCloseDisplay(display)


    (Code adapted from https://stackoverflow.com/questions/29638210/how-can-i-use-python-xlib-to-generate-a-single-keypress)






    share|improve this answer

























    • This works really well, is a life saviour

      – Garret Gang
      Apr 20 at 18:48















    10














    As for Gilles python version not working in newer ubuntus, setting the correct return for the open display seems to do the trick:



    #! /usr/bin/env python

    from ctypes import *
    import subprocess

    class Display(Structure):
    """ opaque struct """

    X11 = cdll.LoadLibrary("libX11.so.6")
    X11.XOpenDisplay.restype = POINTER(Display)

    display = X11.XOpenDisplay(c_int(0))
    X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0))
    X11.XCloseDisplay(display)


    (Code adapted from https://stackoverflow.com/questions/29638210/how-can-i-use-python-xlib-to-generate-a-single-keypress)






    share|improve this answer

























    • This works really well, is a life saviour

      – Garret Gang
      Apr 20 at 18:48













    10












    10








    10







    As for Gilles python version not working in newer ubuntus, setting the correct return for the open display seems to do the trick:



    #! /usr/bin/env python

    from ctypes import *
    import subprocess

    class Display(Structure):
    """ opaque struct """

    X11 = cdll.LoadLibrary("libX11.so.6")
    X11.XOpenDisplay.restype = POINTER(Display)

    display = X11.XOpenDisplay(c_int(0))
    X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0))
    X11.XCloseDisplay(display)


    (Code adapted from https://stackoverflow.com/questions/29638210/how-can-i-use-python-xlib-to-generate-a-single-keypress)






    share|improve this answer















    As for Gilles python version not working in newer ubuntus, setting the correct return for the open display seems to do the trick:



    #! /usr/bin/env python

    from ctypes import *
    import subprocess

    class Display(Structure):
    """ opaque struct """

    X11 = cdll.LoadLibrary("libX11.so.6")
    X11.XOpenDisplay.restype = POINTER(Display)

    display = X11.XOpenDisplay(c_int(0))
    X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0))
    X11.XCloseDisplay(display)


    (Code adapted from https://stackoverflow.com/questions/29638210/how-can-i-use-python-xlib-to-generate-a-single-keypress)







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Apr 28 '18 at 11:43

























    answered Jul 30 '17 at 15:37









    diegogsdiegogs

    20123




    20123












    • This works really well, is a life saviour

      – Garret Gang
      Apr 20 at 18:48

















    • This works really well, is a life saviour

      – Garret Gang
      Apr 20 at 18:48
















    This works really well, is a life saviour

    – Garret Gang
    Apr 20 at 18:48





    This works really well, is a life saviour

    – Garret Gang
    Apr 20 at 18:48











    7














    If you can't access CAPS because you remapped it in .bashrc, like I did, then simply switching to a virtual terminal (alt+ctl+fN) and then switching back worked for me.






    share|improve this answer


















    • 1





      Switching didn't quite do it, but it did get me to a point where I could press caps lock to get thing right.

      – labyrinth
      Feb 16 '18 at 13:33















    7














    If you can't access CAPS because you remapped it in .bashrc, like I did, then simply switching to a virtual terminal (alt+ctl+fN) and then switching back worked for me.






    share|improve this answer


















    • 1





      Switching didn't quite do it, but it did get me to a point where I could press caps lock to get thing right.

      – labyrinth
      Feb 16 '18 at 13:33













    7












    7








    7







    If you can't access CAPS because you remapped it in .bashrc, like I did, then simply switching to a virtual terminal (alt+ctl+fN) and then switching back worked for me.






    share|improve this answer













    If you can't access CAPS because you remapped it in .bashrc, like I did, then simply switching to a virtual terminal (alt+ctl+fN) and then switching back worked for me.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jun 27 '17 at 6:01









    BenjaminBenjamin

    7111




    7111







    • 1





      Switching didn't quite do it, but it did get me to a point where I could press caps lock to get thing right.

      – labyrinth
      Feb 16 '18 at 13:33












    • 1





      Switching didn't quite do it, but it did get me to a point where I could press caps lock to get thing right.

      – labyrinth
      Feb 16 '18 at 13:33







    1




    1





    Switching didn't quite do it, but it did get me to a point where I could press caps lock to get thing right.

    – labyrinth
    Feb 16 '18 at 13:33





    Switching didn't quite do it, but it did get me to a point where I could press caps lock to get thing right.

    – labyrinth
    Feb 16 '18 at 13:33











    1














    I had this problem and was able to fix it by using the OnBoard keyboard (in Ubuntu Mate, under Universal Access).



    Once turned on you should see the CapsLock key is red, or somehow indicated that it is locked on. Then you can press to toggle off.






    share|improve this answer



























      1














      I had this problem and was able to fix it by using the OnBoard keyboard (in Ubuntu Mate, under Universal Access).



      Once turned on you should see the CapsLock key is red, or somehow indicated that it is locked on. Then you can press to toggle off.






      share|improve this answer

























        1












        1








        1







        I had this problem and was able to fix it by using the OnBoard keyboard (in Ubuntu Mate, under Universal Access).



        Once turned on you should see the CapsLock key is red, or somehow indicated that it is locked on. Then you can press to toggle off.






        share|improve this answer













        I had this problem and was able to fix it by using the OnBoard keyboard (in Ubuntu Mate, under Universal Access).



        Once turned on you should see the CapsLock key is red, or somehow indicated that it is locked on. Then you can press to toggle off.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 14 at 18:36









        jogijogi

        112




        112



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f80254%2fhow-do-i-turn-off-caps-lock-the-lock-not-the-key-by-command-line%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Tamil (spriik) Luke uk diar | Nawigatjuun

            Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

            Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?