#include
int main() {
Display * d = XOpenDisplay((char*)0);
bool caps_state = false;
if (d) {
unsigned n;
XkbGetIndicatorState(d, XkbUseCoreKbd, &n);
caps_state = (n & 0x01) == 1;
}
std::cout << "caps_state = " << std::endl;
return 0;
}
Compile above code using
g++ main.cpp -L/usr/X11R6/lib -lX11
Hi, u can replace this line
ReplyDeletecaps_state = (n & 0x01) == 1;
with this
_capslock_state = (n & XInternAtom(QX11Info::display(), "Caps Lock", False)) == 1;
thx you