In Ubuntu C++ how can I get the name of the current keyboard?
I want to use a c++ program not the command line.
For a proper solution you can use D-bus (used for inter-process communication)
sudo apt-get install libdbus-1-dev libdbus-cpp-dev
Alternatively you can try a bit of a hacky solution by installing and adding xkblayout-state to your path and then have a C++ wrapper:
xkblayout-state
#include <cstdlib> int main() { std::system("xkblayout-state print \"%s\""); return 0; }
The above will print out the layout of the keyboard.
For a proper solution you can use D-bus (used for inter-process communication)
Alternatively you can try a bit of a hacky solution by installing and adding
xkblayout-stateto your path and then have a C++ wrapper:The above will print out the layout of the keyboard.