Problem with Caps Lock key in Elementary OS 5.1
scellige opened this issue · 0 comments
scellige commented
Hello, If I try to use CapsLock as a hotkey for change keyboard layout there is a problem:
- If I disable CapsLock key in system settings - the script doesn't handle keypress events
- If I don't disable CapsLock key - the script works, but it also changes the state of CapsLock, and in new keyboard's layout you will type capital letters
I found a solution:
In the start of file switch-layout.py add this:
from ctypes import *
class Display(Structure):
""" opaque struct """
And at the end of the method on_press
of the Switcher
class add this:
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)