user3443063
user3443063

Reputation: 1623

ubuntu c++ how get the name of the current active keyboard

In Ubuntu C++ how can I get the name of the current keyboard?

I want to use a c++ program not the command line.

Upvotes: 0

Views: 75

Answers (1)

Hadi
Hadi

Reputation: 1005

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:

#include <cstdlib>

int main() {
    std::system("xkblayout-state print \"%s\"");
    return 0;
}

The above will print out the layout of the keyboard.

Upvotes: 1

Related Questions