Change the status of the keyboard leds, from within an X session, without root access

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
9
down vote

favorite
3












I am trying to force the capslock led on. xset does not work for me, so I am trying to use setleds.



In a graphical console, this command returns:



> LANG=C setleds -L +caps
KDGKBLED: Inappropriate ioctl for device
Error reading current flags setting. Maybe you are not on the console?


In a virtual terminal, it works, however the effect is local to that virtual terminal. From what I understand, running



> setleds -L +caps < /dev/tty1


from a virtual terminal (my X server is sitting on tty1) should work. However, this requires root access.



Is there a way to send a command to the console underlying a X server, be it from the said xserver or from another VT, without root?



Edit: From a suggestion from Mark Plotnik, and based on code found here, I wrote and compiled the following:





#include <X11/Xlib.h>
#include <X11/XKBlib.h>

#define SCROLLLOCK 1
#define CAPSLOCK 2
#define NUMLOCK 16

void setLeds(int leds) NUMLOCK,
leds & (CAPSLOCK

int main()
setLeds(CAPSLOCK);
return 0;



From what Gilles wrote about xset, I did not expect it to work, but it does... in some sense: it sets the led, but it also sets the capslock status. I do not fully understand all the code above, so I may have done a silly mistake. Apparently, the line XChangeKeyboardControl... does not change the behavior of the program, and XkbLockModifiers is what sets the led and the capslock status.










share|improve this question























  • You can do something like xdotool key Caps_Lock from an authorized X client, although this will actually turn on caps lock.
    – Mark Plotnick
    Jan 15 '15 at 18:53










  • @MarkPlotnick The point is indeed not to turn CapsLock on. Is there a way to turn CapsLock off, without touching the led?
    – T. Verron
    Jan 15 '15 at 19:06










  • I looked at the xterm source, and it uses a call to XChangeKeyboardControl() to set or unset the LEDs without affecting the state of caps lock etc. So if you can compile C code, that's one approach.
    – Mark Plotnick
    Jan 15 '15 at 20:43










  • @MarkPlotnick Does xterm affect the leds? It sounds like a good idea, I will edit the question with my results.
    – T. Verron
    Jan 16 '15 at 8:58










  • I got xterm to light up ScrollLock LED by sending the escape sequence ESC [ 3 q , as per the file ctlseqs.txt that comes with the source, but couldn't get the Num or CapsLock LEDs to light up with parameters 1 and 2. Maybe I need to do the XKB configuration mentioned in the answer. xterm calls XChangeKeyboardControl in xtermShowLED and xtermClearLEDs, but doesn't call XkbLockModifiers anywhere at all.
    – Mark Plotnick
    Jan 16 '15 at 15:48














up vote
9
down vote

favorite
3












I am trying to force the capslock led on. xset does not work for me, so I am trying to use setleds.



In a graphical console, this command returns:



> LANG=C setleds -L +caps
KDGKBLED: Inappropriate ioctl for device
Error reading current flags setting. Maybe you are not on the console?


In a virtual terminal, it works, however the effect is local to that virtual terminal. From what I understand, running



> setleds -L +caps < /dev/tty1


from a virtual terminal (my X server is sitting on tty1) should work. However, this requires root access.



Is there a way to send a command to the console underlying a X server, be it from the said xserver or from another VT, without root?



Edit: From a suggestion from Mark Plotnik, and based on code found here, I wrote and compiled the following:





#include <X11/Xlib.h>
#include <X11/XKBlib.h>

#define SCROLLLOCK 1
#define CAPSLOCK 2
#define NUMLOCK 16

void setLeds(int leds) NUMLOCK,
leds & (CAPSLOCK

int main()
setLeds(CAPSLOCK);
return 0;



From what Gilles wrote about xset, I did not expect it to work, but it does... in some sense: it sets the led, but it also sets the capslock status. I do not fully understand all the code above, so I may have done a silly mistake. Apparently, the line XChangeKeyboardControl... does not change the behavior of the program, and XkbLockModifiers is what sets the led and the capslock status.










share|improve this question























  • You can do something like xdotool key Caps_Lock from an authorized X client, although this will actually turn on caps lock.
    – Mark Plotnick
    Jan 15 '15 at 18:53










  • @MarkPlotnick The point is indeed not to turn CapsLock on. Is there a way to turn CapsLock off, without touching the led?
    – T. Verron
    Jan 15 '15 at 19:06










  • I looked at the xterm source, and it uses a call to XChangeKeyboardControl() to set or unset the LEDs without affecting the state of caps lock etc. So if you can compile C code, that's one approach.
    – Mark Plotnick
    Jan 15 '15 at 20:43










  • @MarkPlotnick Does xterm affect the leds? It sounds like a good idea, I will edit the question with my results.
    – T. Verron
    Jan 16 '15 at 8:58










  • I got xterm to light up ScrollLock LED by sending the escape sequence ESC [ 3 q , as per the file ctlseqs.txt that comes with the source, but couldn't get the Num or CapsLock LEDs to light up with parameters 1 and 2. Maybe I need to do the XKB configuration mentioned in the answer. xterm calls XChangeKeyboardControl in xtermShowLED and xtermClearLEDs, but doesn't call XkbLockModifiers anywhere at all.
    – Mark Plotnick
    Jan 16 '15 at 15:48












up vote
9
down vote

favorite
3









up vote
9
down vote

favorite
3






3





I am trying to force the capslock led on. xset does not work for me, so I am trying to use setleds.



In a graphical console, this command returns:



> LANG=C setleds -L +caps
KDGKBLED: Inappropriate ioctl for device
Error reading current flags setting. Maybe you are not on the console?


In a virtual terminal, it works, however the effect is local to that virtual terminal. From what I understand, running



> setleds -L +caps < /dev/tty1


from a virtual terminal (my X server is sitting on tty1) should work. However, this requires root access.



Is there a way to send a command to the console underlying a X server, be it from the said xserver or from another VT, without root?



Edit: From a suggestion from Mark Plotnik, and based on code found here, I wrote and compiled the following:





#include <X11/Xlib.h>
#include <X11/XKBlib.h>

#define SCROLLLOCK 1
#define CAPSLOCK 2
#define NUMLOCK 16

void setLeds(int leds) NUMLOCK,
leds & (CAPSLOCK

int main()
setLeds(CAPSLOCK);
return 0;



From what Gilles wrote about xset, I did not expect it to work, but it does... in some sense: it sets the led, but it also sets the capslock status. I do not fully understand all the code above, so I may have done a silly mistake. Apparently, the line XChangeKeyboardControl... does not change the behavior of the program, and XkbLockModifiers is what sets the led and the capslock status.










share|improve this question















I am trying to force the capslock led on. xset does not work for me, so I am trying to use setleds.



In a graphical console, this command returns:



> LANG=C setleds -L +caps
KDGKBLED: Inappropriate ioctl for device
Error reading current flags setting. Maybe you are not on the console?


In a virtual terminal, it works, however the effect is local to that virtual terminal. From what I understand, running



> setleds -L +caps < /dev/tty1


from a virtual terminal (my X server is sitting on tty1) should work. However, this requires root access.



Is there a way to send a command to the console underlying a X server, be it from the said xserver or from another VT, without root?



Edit: From a suggestion from Mark Plotnik, and based on code found here, I wrote and compiled the following:





#include <X11/Xlib.h>
#include <X11/XKBlib.h>

#define SCROLLLOCK 1
#define CAPSLOCK 2
#define NUMLOCK 16

void setLeds(int leds) NUMLOCK,
leds & (CAPSLOCK

int main()
setLeds(CAPSLOCK);
return 0;



From what Gilles wrote about xset, I did not expect it to work, but it does... in some sense: it sets the led, but it also sets the capslock status. I do not fully understand all the code above, so I may have done a silly mistake. Apparently, the line XChangeKeyboardControl... does not change the behavior of the program, and XkbLockModifiers is what sets the led and the capslock status.







linux x11 xorg io-redirection console






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 16 '15 at 9:26

























asked Jan 15 '15 at 15:57









T. Verron

21026




21026











  • You can do something like xdotool key Caps_Lock from an authorized X client, although this will actually turn on caps lock.
    – Mark Plotnick
    Jan 15 '15 at 18:53










  • @MarkPlotnick The point is indeed not to turn CapsLock on. Is there a way to turn CapsLock off, without touching the led?
    – T. Verron
    Jan 15 '15 at 19:06










  • I looked at the xterm source, and it uses a call to XChangeKeyboardControl() to set or unset the LEDs without affecting the state of caps lock etc. So if you can compile C code, that's one approach.
    – Mark Plotnick
    Jan 15 '15 at 20:43










  • @MarkPlotnick Does xterm affect the leds? It sounds like a good idea, I will edit the question with my results.
    – T. Verron
    Jan 16 '15 at 8:58










  • I got xterm to light up ScrollLock LED by sending the escape sequence ESC [ 3 q , as per the file ctlseqs.txt that comes with the source, but couldn't get the Num or CapsLock LEDs to light up with parameters 1 and 2. Maybe I need to do the XKB configuration mentioned in the answer. xterm calls XChangeKeyboardControl in xtermShowLED and xtermClearLEDs, but doesn't call XkbLockModifiers anywhere at all.
    – Mark Plotnick
    Jan 16 '15 at 15:48
















  • You can do something like xdotool key Caps_Lock from an authorized X client, although this will actually turn on caps lock.
    – Mark Plotnick
    Jan 15 '15 at 18:53










  • @MarkPlotnick The point is indeed not to turn CapsLock on. Is there a way to turn CapsLock off, without touching the led?
    – T. Verron
    Jan 15 '15 at 19:06










  • I looked at the xterm source, and it uses a call to XChangeKeyboardControl() to set or unset the LEDs without affecting the state of caps lock etc. So if you can compile C code, that's one approach.
    – Mark Plotnick
    Jan 15 '15 at 20:43










  • @MarkPlotnick Does xterm affect the leds? It sounds like a good idea, I will edit the question with my results.
    – T. Verron
    Jan 16 '15 at 8:58










  • I got xterm to light up ScrollLock LED by sending the escape sequence ESC [ 3 q , as per the file ctlseqs.txt that comes with the source, but couldn't get the Num or CapsLock LEDs to light up with parameters 1 and 2. Maybe I need to do the XKB configuration mentioned in the answer. xterm calls XChangeKeyboardControl in xtermShowLED and xtermClearLEDs, but doesn't call XkbLockModifiers anywhere at all.
    – Mark Plotnick
    Jan 16 '15 at 15:48















You can do something like xdotool key Caps_Lock from an authorized X client, although this will actually turn on caps lock.
– Mark Plotnick
Jan 15 '15 at 18:53




You can do something like xdotool key Caps_Lock from an authorized X client, although this will actually turn on caps lock.
– Mark Plotnick
Jan 15 '15 at 18:53












@MarkPlotnick The point is indeed not to turn CapsLock on. Is there a way to turn CapsLock off, without touching the led?
– T. Verron
Jan 15 '15 at 19:06




@MarkPlotnick The point is indeed not to turn CapsLock on. Is there a way to turn CapsLock off, without touching the led?
– T. Verron
Jan 15 '15 at 19:06












I looked at the xterm source, and it uses a call to XChangeKeyboardControl() to set or unset the LEDs without affecting the state of caps lock etc. So if you can compile C code, that's one approach.
– Mark Plotnick
Jan 15 '15 at 20:43




I looked at the xterm source, and it uses a call to XChangeKeyboardControl() to set or unset the LEDs without affecting the state of caps lock etc. So if you can compile C code, that's one approach.
– Mark Plotnick
Jan 15 '15 at 20:43












@MarkPlotnick Does xterm affect the leds? It sounds like a good idea, I will edit the question with my results.
– T. Verron
Jan 16 '15 at 8:58




@MarkPlotnick Does xterm affect the leds? It sounds like a good idea, I will edit the question with my results.
– T. Verron
Jan 16 '15 at 8:58












I got xterm to light up ScrollLock LED by sending the escape sequence ESC [ 3 q , as per the file ctlseqs.txt that comes with the source, but couldn't get the Num or CapsLock LEDs to light up with parameters 1 and 2. Maybe I need to do the XKB configuration mentioned in the answer. xterm calls XChangeKeyboardControl in xtermShowLED and xtermClearLEDs, but doesn't call XkbLockModifiers anywhere at all.
– Mark Plotnick
Jan 16 '15 at 15:48




I got xterm to light up ScrollLock LED by sending the escape sequence ESC [ 3 q , as per the file ctlseqs.txt that comes with the source, but couldn't get the Num or CapsLock LEDs to light up with parameters 1 and 2. Maybe I need to do the XKB configuration mentioned in the answer. xterm calls XChangeKeyboardControl in xtermShowLED and xtermClearLEDs, but doesn't call XkbLockModifiers anywhere at all.
– Mark Plotnick
Jan 16 '15 at 15:48










2 Answers
2






active

oldest

votes

















up vote
7
down vote



accepted










In principle, you should be able to do it with the venerable xset command.



xset led named 'Caps Lock'


or xset led 4 to set LED number 4, if your system doesn't recognize the LEDs by name.



However, this doesn't seem to work reliably. On my machine, I can only set Scroll Lock this way, and I'm not the only one. This seems to be a matter of XKB configuration.



The following user-level work-around should work (for the most part):




  1. Extract your current xkb configuration:



    xkbcomp $DISPLAY myconf.xkb



  2. Edit the file myconf.xkb, replacing !allowExplicit with allowExplicit in the relevant blocks:



    indicator "Caps Lock" 
    allowExplicit;
    whichModState= locked;
    modifiers= Lock;
    ;
    indicator "Num Lock"
    allowExplicit;
    whichModState= locked;
    modifiers= NumLock;
    ;



  3. Load the new file



    xkbcomp myconf.xkb $DISPLAY


Now setting the leds on and off with xset should work. According to the bug report, you will not be able to switch the leds off when they are supposed to be on (for example if CapsLock is enabled).






share|improve this answer






















  • Thanks! I had tried xset before, and indeed it does not work. I had not seen this bug report though. Anyway, "Status: Resolved Wontfix" is not really encouraging... The allowExplicit work-around would probably work for me (I don't need to turn the led off), but changing it still requires root.
    – T. Verron
    Jan 16 '15 at 9:16










  • @T.Verron You don't need to be root to change the XKB configuration. You can call xkbcomp at any time. I'm not familiar enough with XKB to tell you exactly what you need to change (setting a specific aspect rather than a full predefined map with XKB is a bit of a pain), but unix.stackexchange.com/questions/166844/mapping-key-bindings/… should have a few pointers.
    – Gilles
    Jan 16 '15 at 9:30










  • Oh, good point. Well, as a first attempt, I tried: xkbcomp $DISPLAY output.xkb, then replacing !allowExplicit by allowExplicit in the indicator "Caps Lock" section, then reloading the file with xkbcomp output.xkb. There is a lot of warnings, and xset doesn't work any better afterwards. I will read some more about xkb.
    – T. Verron
    Jan 16 '15 at 12:49






  • 1




    This kind of worked for me. After I imported the modified file I got some error messages and I could light the LEDs but other things got messed up, plus it did not survive a restart. So I went ahead an edited /usr/share/X11/xkb/compat/ledcaps and .../lednum and this made it permanent.
    – jtgd
    Jun 26 at 0:47

















up vote
0
down vote













Using sed



$ sudo sed -i 's|!allowExplicit|allowExplicit|g' /usr/share/X11/xkb/compat/ledcaps


After logging out and in again, the Caps Lock LED can now be controlled without any root privileges using the commands:



$ xset led named 'Caps Lock'
$ xset -led named 'Caps Lock'





share|improve this answer




















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    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',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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%2funix.stackexchange.com%2fquestions%2f179286%2fchange-the-status-of-the-keyboard-leds-from-within-an-x-session-without-root-a%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    7
    down vote



    accepted










    In principle, you should be able to do it with the venerable xset command.



    xset led named 'Caps Lock'


    or xset led 4 to set LED number 4, if your system doesn't recognize the LEDs by name.



    However, this doesn't seem to work reliably. On my machine, I can only set Scroll Lock this way, and I'm not the only one. This seems to be a matter of XKB configuration.



    The following user-level work-around should work (for the most part):




    1. Extract your current xkb configuration:



      xkbcomp $DISPLAY myconf.xkb



    2. Edit the file myconf.xkb, replacing !allowExplicit with allowExplicit in the relevant blocks:



      indicator "Caps Lock" 
      allowExplicit;
      whichModState= locked;
      modifiers= Lock;
      ;
      indicator "Num Lock"
      allowExplicit;
      whichModState= locked;
      modifiers= NumLock;
      ;



    3. Load the new file



      xkbcomp myconf.xkb $DISPLAY


    Now setting the leds on and off with xset should work. According to the bug report, you will not be able to switch the leds off when they are supposed to be on (for example if CapsLock is enabled).






    share|improve this answer






















    • Thanks! I had tried xset before, and indeed it does not work. I had not seen this bug report though. Anyway, "Status: Resolved Wontfix" is not really encouraging... The allowExplicit work-around would probably work for me (I don't need to turn the led off), but changing it still requires root.
      – T. Verron
      Jan 16 '15 at 9:16










    • @T.Verron You don't need to be root to change the XKB configuration. You can call xkbcomp at any time. I'm not familiar enough with XKB to tell you exactly what you need to change (setting a specific aspect rather than a full predefined map with XKB is a bit of a pain), but unix.stackexchange.com/questions/166844/mapping-key-bindings/… should have a few pointers.
      – Gilles
      Jan 16 '15 at 9:30










    • Oh, good point. Well, as a first attempt, I tried: xkbcomp $DISPLAY output.xkb, then replacing !allowExplicit by allowExplicit in the indicator "Caps Lock" section, then reloading the file with xkbcomp output.xkb. There is a lot of warnings, and xset doesn't work any better afterwards. I will read some more about xkb.
      – T. Verron
      Jan 16 '15 at 12:49






    • 1




      This kind of worked for me. After I imported the modified file I got some error messages and I could light the LEDs but other things got messed up, plus it did not survive a restart. So I went ahead an edited /usr/share/X11/xkb/compat/ledcaps and .../lednum and this made it permanent.
      – jtgd
      Jun 26 at 0:47














    up vote
    7
    down vote



    accepted










    In principle, you should be able to do it with the venerable xset command.



    xset led named 'Caps Lock'


    or xset led 4 to set LED number 4, if your system doesn't recognize the LEDs by name.



    However, this doesn't seem to work reliably. On my machine, I can only set Scroll Lock this way, and I'm not the only one. This seems to be a matter of XKB configuration.



    The following user-level work-around should work (for the most part):




    1. Extract your current xkb configuration:



      xkbcomp $DISPLAY myconf.xkb



    2. Edit the file myconf.xkb, replacing !allowExplicit with allowExplicit in the relevant blocks:



      indicator "Caps Lock" 
      allowExplicit;
      whichModState= locked;
      modifiers= Lock;
      ;
      indicator "Num Lock"
      allowExplicit;
      whichModState= locked;
      modifiers= NumLock;
      ;



    3. Load the new file



      xkbcomp myconf.xkb $DISPLAY


    Now setting the leds on and off with xset should work. According to the bug report, you will not be able to switch the leds off when they are supposed to be on (for example if CapsLock is enabled).






    share|improve this answer






















    • Thanks! I had tried xset before, and indeed it does not work. I had not seen this bug report though. Anyway, "Status: Resolved Wontfix" is not really encouraging... The allowExplicit work-around would probably work for me (I don't need to turn the led off), but changing it still requires root.
      – T. Verron
      Jan 16 '15 at 9:16










    • @T.Verron You don't need to be root to change the XKB configuration. You can call xkbcomp at any time. I'm not familiar enough with XKB to tell you exactly what you need to change (setting a specific aspect rather than a full predefined map with XKB is a bit of a pain), but unix.stackexchange.com/questions/166844/mapping-key-bindings/… should have a few pointers.
      – Gilles
      Jan 16 '15 at 9:30










    • Oh, good point. Well, as a first attempt, I tried: xkbcomp $DISPLAY output.xkb, then replacing !allowExplicit by allowExplicit in the indicator "Caps Lock" section, then reloading the file with xkbcomp output.xkb. There is a lot of warnings, and xset doesn't work any better afterwards. I will read some more about xkb.
      – T. Verron
      Jan 16 '15 at 12:49






    • 1




      This kind of worked for me. After I imported the modified file I got some error messages and I could light the LEDs but other things got messed up, plus it did not survive a restart. So I went ahead an edited /usr/share/X11/xkb/compat/ledcaps and .../lednum and this made it permanent.
      – jtgd
      Jun 26 at 0:47












    up vote
    7
    down vote



    accepted







    up vote
    7
    down vote



    accepted






    In principle, you should be able to do it with the venerable xset command.



    xset led named 'Caps Lock'


    or xset led 4 to set LED number 4, if your system doesn't recognize the LEDs by name.



    However, this doesn't seem to work reliably. On my machine, I can only set Scroll Lock this way, and I'm not the only one. This seems to be a matter of XKB configuration.



    The following user-level work-around should work (for the most part):




    1. Extract your current xkb configuration:



      xkbcomp $DISPLAY myconf.xkb



    2. Edit the file myconf.xkb, replacing !allowExplicit with allowExplicit in the relevant blocks:



      indicator "Caps Lock" 
      allowExplicit;
      whichModState= locked;
      modifiers= Lock;
      ;
      indicator "Num Lock"
      allowExplicit;
      whichModState= locked;
      modifiers= NumLock;
      ;



    3. Load the new file



      xkbcomp myconf.xkb $DISPLAY


    Now setting the leds on and off with xset should work. According to the bug report, you will not be able to switch the leds off when they are supposed to be on (for example if CapsLock is enabled).






    share|improve this answer














    In principle, you should be able to do it with the venerable xset command.



    xset led named 'Caps Lock'


    or xset led 4 to set LED number 4, if your system doesn't recognize the LEDs by name.



    However, this doesn't seem to work reliably. On my machine, I can only set Scroll Lock this way, and I'm not the only one. This seems to be a matter of XKB configuration.



    The following user-level work-around should work (for the most part):




    1. Extract your current xkb configuration:



      xkbcomp $DISPLAY myconf.xkb



    2. Edit the file myconf.xkb, replacing !allowExplicit with allowExplicit in the relevant blocks:



      indicator "Caps Lock" 
      allowExplicit;
      whichModState= locked;
      modifiers= Lock;
      ;
      indicator "Num Lock"
      allowExplicit;
      whichModState= locked;
      modifiers= NumLock;
      ;



    3. Load the new file



      xkbcomp myconf.xkb $DISPLAY


    Now setting the leds on and off with xset should work. According to the bug report, you will not be able to switch the leds off when they are supposed to be on (for example if CapsLock is enabled).







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited May 23 '17 at 11:33









    Community♦

    1




    1










    answered Jan 16 '15 at 0:38









    Gilles

    518k12410331563




    518k12410331563











    • Thanks! I had tried xset before, and indeed it does not work. I had not seen this bug report though. Anyway, "Status: Resolved Wontfix" is not really encouraging... The allowExplicit work-around would probably work for me (I don't need to turn the led off), but changing it still requires root.
      – T. Verron
      Jan 16 '15 at 9:16










    • @T.Verron You don't need to be root to change the XKB configuration. You can call xkbcomp at any time. I'm not familiar enough with XKB to tell you exactly what you need to change (setting a specific aspect rather than a full predefined map with XKB is a bit of a pain), but unix.stackexchange.com/questions/166844/mapping-key-bindings/… should have a few pointers.
      – Gilles
      Jan 16 '15 at 9:30










    • Oh, good point. Well, as a first attempt, I tried: xkbcomp $DISPLAY output.xkb, then replacing !allowExplicit by allowExplicit in the indicator "Caps Lock" section, then reloading the file with xkbcomp output.xkb. There is a lot of warnings, and xset doesn't work any better afterwards. I will read some more about xkb.
      – T. Verron
      Jan 16 '15 at 12:49






    • 1




      This kind of worked for me. After I imported the modified file I got some error messages and I could light the LEDs but other things got messed up, plus it did not survive a restart. So I went ahead an edited /usr/share/X11/xkb/compat/ledcaps and .../lednum and this made it permanent.
      – jtgd
      Jun 26 at 0:47
















    • Thanks! I had tried xset before, and indeed it does not work. I had not seen this bug report though. Anyway, "Status: Resolved Wontfix" is not really encouraging... The allowExplicit work-around would probably work for me (I don't need to turn the led off), but changing it still requires root.
      – T. Verron
      Jan 16 '15 at 9:16










    • @T.Verron You don't need to be root to change the XKB configuration. You can call xkbcomp at any time. I'm not familiar enough with XKB to tell you exactly what you need to change (setting a specific aspect rather than a full predefined map with XKB is a bit of a pain), but unix.stackexchange.com/questions/166844/mapping-key-bindings/… should have a few pointers.
      – Gilles
      Jan 16 '15 at 9:30










    • Oh, good point. Well, as a first attempt, I tried: xkbcomp $DISPLAY output.xkb, then replacing !allowExplicit by allowExplicit in the indicator "Caps Lock" section, then reloading the file with xkbcomp output.xkb. There is a lot of warnings, and xset doesn't work any better afterwards. I will read some more about xkb.
      – T. Verron
      Jan 16 '15 at 12:49






    • 1




      This kind of worked for me. After I imported the modified file I got some error messages and I could light the LEDs but other things got messed up, plus it did not survive a restart. So I went ahead an edited /usr/share/X11/xkb/compat/ledcaps and .../lednum and this made it permanent.
      – jtgd
      Jun 26 at 0:47















    Thanks! I had tried xset before, and indeed it does not work. I had not seen this bug report though. Anyway, "Status: Resolved Wontfix" is not really encouraging... The allowExplicit work-around would probably work for me (I don't need to turn the led off), but changing it still requires root.
    – T. Verron
    Jan 16 '15 at 9:16




    Thanks! I had tried xset before, and indeed it does not work. I had not seen this bug report though. Anyway, "Status: Resolved Wontfix" is not really encouraging... The allowExplicit work-around would probably work for me (I don't need to turn the led off), but changing it still requires root.
    – T. Verron
    Jan 16 '15 at 9:16












    @T.Verron You don't need to be root to change the XKB configuration. You can call xkbcomp at any time. I'm not familiar enough with XKB to tell you exactly what you need to change (setting a specific aspect rather than a full predefined map with XKB is a bit of a pain), but unix.stackexchange.com/questions/166844/mapping-key-bindings/… should have a few pointers.
    – Gilles
    Jan 16 '15 at 9:30




    @T.Verron You don't need to be root to change the XKB configuration. You can call xkbcomp at any time. I'm not familiar enough with XKB to tell you exactly what you need to change (setting a specific aspect rather than a full predefined map with XKB is a bit of a pain), but unix.stackexchange.com/questions/166844/mapping-key-bindings/… should have a few pointers.
    – Gilles
    Jan 16 '15 at 9:30












    Oh, good point. Well, as a first attempt, I tried: xkbcomp $DISPLAY output.xkb, then replacing !allowExplicit by allowExplicit in the indicator "Caps Lock" section, then reloading the file with xkbcomp output.xkb. There is a lot of warnings, and xset doesn't work any better afterwards. I will read some more about xkb.
    – T. Verron
    Jan 16 '15 at 12:49




    Oh, good point. Well, as a first attempt, I tried: xkbcomp $DISPLAY output.xkb, then replacing !allowExplicit by allowExplicit in the indicator "Caps Lock" section, then reloading the file with xkbcomp output.xkb. There is a lot of warnings, and xset doesn't work any better afterwards. I will read some more about xkb.
    – T. Verron
    Jan 16 '15 at 12:49




    1




    1




    This kind of worked for me. After I imported the modified file I got some error messages and I could light the LEDs but other things got messed up, plus it did not survive a restart. So I went ahead an edited /usr/share/X11/xkb/compat/ledcaps and .../lednum and this made it permanent.
    – jtgd
    Jun 26 at 0:47




    This kind of worked for me. After I imported the modified file I got some error messages and I could light the LEDs but other things got messed up, plus it did not survive a restart. So I went ahead an edited /usr/share/X11/xkb/compat/ledcaps and .../lednum and this made it permanent.
    – jtgd
    Jun 26 at 0:47












    up vote
    0
    down vote













    Using sed



    $ sudo sed -i 's|!allowExplicit|allowExplicit|g' /usr/share/X11/xkb/compat/ledcaps


    After logging out and in again, the Caps Lock LED can now be controlled without any root privileges using the commands:



    $ xset led named 'Caps Lock'
    $ xset -led named 'Caps Lock'





    share|improve this answer
























      up vote
      0
      down vote













      Using sed



      $ sudo sed -i 's|!allowExplicit|allowExplicit|g' /usr/share/X11/xkb/compat/ledcaps


      After logging out and in again, the Caps Lock LED can now be controlled without any root privileges using the commands:



      $ xset led named 'Caps Lock'
      $ xset -led named 'Caps Lock'





      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        Using sed



        $ sudo sed -i 's|!allowExplicit|allowExplicit|g' /usr/share/X11/xkb/compat/ledcaps


        After logging out and in again, the Caps Lock LED can now be controlled without any root privileges using the commands:



        $ xset led named 'Caps Lock'
        $ xset -led named 'Caps Lock'





        share|improve this answer












        Using sed



        $ sudo sed -i 's|!allowExplicit|allowExplicit|g' /usr/share/X11/xkb/compat/ledcaps


        After logging out and in again, the Caps Lock LED can now be controlled without any root privileges using the commands:



        $ xset led named 'Caps Lock'
        $ xset -led named 'Caps Lock'






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 12 mins ago









        Serge Stroobandt

        79121225




        79121225



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f179286%2fchange-the-status-of-the-keyboard-leds-from-within-an-x-session-without-root-a%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)