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

Clash Royale CLAN TAG#URR8PPP
up vote
9
down vote
favorite
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
add a comment |Â
up vote
9
down vote
favorite
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
You can do something likexdotool key Caps_Lockfrom 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 thextermsource, 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 Doesxtermaffect 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 gotxtermto light up ScrollLock LED by sending the escape sequence ESC [ 3 q , as per the filectlseqs.txtthat 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.xtermcallsXChangeKeyboardControlinxtermShowLEDandxtermClearLEDs, but doesn't callXkbLockModifiersanywhere at all.
â Mark Plotnick
Jan 16 '15 at 15:48
add a comment |Â
up vote
9
down vote
favorite
up vote
9
down vote
favorite
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
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
linux x11 xorg io-redirection console
edited Jan 16 '15 at 9:26
asked Jan 15 '15 at 15:57
T. Verron
21026
21026
You can do something likexdotool key Caps_Lockfrom 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 thextermsource, 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 Doesxtermaffect 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 gotxtermto light up ScrollLock LED by sending the escape sequence ESC [ 3 q , as per the filectlseqs.txtthat 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.xtermcallsXChangeKeyboardControlinxtermShowLEDandxtermClearLEDs, but doesn't callXkbLockModifiersanywhere at all.
â Mark Plotnick
Jan 16 '15 at 15:48
add a comment |Â
You can do something likexdotool key Caps_Lockfrom 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 thextermsource, 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 Doesxtermaffect 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 gotxtermto light up ScrollLock LED by sending the escape sequence ESC [ 3 q , as per the filectlseqs.txtthat 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.xtermcallsXChangeKeyboardControlinxtermShowLEDandxtermClearLEDs, but doesn't callXkbLockModifiersanywhere 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
add a comment |Â
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):
Extract your current xkb configuration:
xkbcomp $DISPLAY myconf.xkbEdit the file
myconf.xkb, replacing!allowExplicitwithallowExplicitin the relevant blocks:indicator "Caps Lock"
allowExplicit;
whichModState= locked;
modifiers= Lock;
;
indicator "Num Lock"
allowExplicit;
whichModState= locked;
modifiers= NumLock;
;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).
Thanks! I had triedxsetbefore, and indeed it does not work. I had not seen this bug report though. Anyway, "Status: Resolved Wontfix" is not really encouraging... TheallowExplicitwork-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 callxkbcompat 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!allowExplicitbyallowExplicitin theindicator "Caps Lock"section, then reloading the file withxkbcomp 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/ledcapsand .../lednum and this made it permanent.
â jtgd
Jun 26 at 0:47
add a comment |Â
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'
add a comment |Â
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):
Extract your current xkb configuration:
xkbcomp $DISPLAY myconf.xkbEdit the file
myconf.xkb, replacing!allowExplicitwithallowExplicitin the relevant blocks:indicator "Caps Lock"
allowExplicit;
whichModState= locked;
modifiers= Lock;
;
indicator "Num Lock"
allowExplicit;
whichModState= locked;
modifiers= NumLock;
;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).
Thanks! I had triedxsetbefore, and indeed it does not work. I had not seen this bug report though. Anyway, "Status: Resolved Wontfix" is not really encouraging... TheallowExplicitwork-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 callxkbcompat 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!allowExplicitbyallowExplicitin theindicator "Caps Lock"section, then reloading the file withxkbcomp 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/ledcapsand .../lednum and this made it permanent.
â jtgd
Jun 26 at 0:47
add a comment |Â
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):
Extract your current xkb configuration:
xkbcomp $DISPLAY myconf.xkbEdit the file
myconf.xkb, replacing!allowExplicitwithallowExplicitin the relevant blocks:indicator "Caps Lock"
allowExplicit;
whichModState= locked;
modifiers= Lock;
;
indicator "Num Lock"
allowExplicit;
whichModState= locked;
modifiers= NumLock;
;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).
Thanks! I had triedxsetbefore, and indeed it does not work. I had not seen this bug report though. Anyway, "Status: Resolved Wontfix" is not really encouraging... TheallowExplicitwork-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 callxkbcompat 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!allowExplicitbyallowExplicitin theindicator "Caps Lock"section, then reloading the file withxkbcomp 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/ledcapsand .../lednum and this made it permanent.
â jtgd
Jun 26 at 0:47
add a comment |Â
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):
Extract your current xkb configuration:
xkbcomp $DISPLAY myconf.xkbEdit the file
myconf.xkb, replacing!allowExplicitwithallowExplicitin the relevant blocks:indicator "Caps Lock"
allowExplicit;
whichModState= locked;
modifiers= Lock;
;
indicator "Num Lock"
allowExplicit;
whichModState= locked;
modifiers= NumLock;
;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).
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):
Extract your current xkb configuration:
xkbcomp $DISPLAY myconf.xkbEdit the file
myconf.xkb, replacing!allowExplicitwithallowExplicitin the relevant blocks:indicator "Caps Lock"
allowExplicit;
whichModState= locked;
modifiers= Lock;
;
indicator "Num Lock"
allowExplicit;
whichModState= locked;
modifiers= NumLock;
;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).
edited May 23 '17 at 11:33
Communityâ¦
1
1
answered Jan 16 '15 at 0:38
Gilles
518k12410331563
518k12410331563
Thanks! I had triedxsetbefore, and indeed it does not work. I had not seen this bug report though. Anyway, "Status: Resolved Wontfix" is not really encouraging... TheallowExplicitwork-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 callxkbcompat 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!allowExplicitbyallowExplicitin theindicator "Caps Lock"section, then reloading the file withxkbcomp 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/ledcapsand .../lednum and this made it permanent.
â jtgd
Jun 26 at 0:47
add a comment |Â
Thanks! I had triedxsetbefore, and indeed it does not work. I had not seen this bug report though. Anyway, "Status: Resolved Wontfix" is not really encouraging... TheallowExplicitwork-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 callxkbcompat 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!allowExplicitbyallowExplicitin theindicator "Caps Lock"section, then reloading the file withxkbcomp 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/ledcapsand .../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
add a comment |Â
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'
add a comment |Â
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'
add a comment |Â
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'
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'
answered 12 mins ago
Serge Stroobandt
79121225
79121225
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
You can do something like
xdotool key Caps_Lockfrom 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
xtermsource, 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
xtermaffect 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
xtermto light up ScrollLock LED by sending the escape sequence ESC [ 3 q , as per the filectlseqs.txtthat 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.xtermcallsXChangeKeyboardControlinxtermShowLEDandxtermClearLEDs, but doesn't callXkbLockModifiersanywhere at all.â Mark Plotnick
Jan 16 '15 at 15:48