2

Often when using nomachine the functionality of the caps lock key will suddenly toggle. Usually it will revert back to normal after a while. But now I have a situation where it had not reverted back after a few days, nor after restarting my session. Does anyone know a way to fix this?

Larry Martell
  • 3,526
  • 6
  • 40
  • 76

1 Answers1

12

A colleague of mine found a solution to this. Running the following python code on the remote Linux/Un*x system fixed the problem:

from ctypes import *
X11 = cdll.LoadLibrary("libX11.so.6")
display = X11.XOpenDisplay(None)
X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(2))
X11.XCloseDisplay(display)
Travis
  • 43
  • 5
Larry Martell
  • 3,526
  • 6
  • 40
  • 76
  • did you find the root cause of this issue? – badmad Nov 24 '15 at 19:23
  • To expand on @LarryMartell the first c_uint(2) is the mask indicating the second bit which is the cap lock. The second c_uint(2) is the value indicating that you want to turn it on. If you need to turn it off, simply change the final argument to c_uint(0). – Keith Hanlan Apr 18 '18 at 15:22
  • One more point: If you want to toggle rather than set, you will need to know the current state. That requires the use of the XkbGetState API which passes the address of a struct which you will need to define. Refer to https://stackoverflow.com/a/2573493/2359145 for code which does exactly this. – Keith Hanlan Apr 18 '18 at 15:37