On Linux, the windowing system is key for displaying and interacting with graphical interfaces. Two common ones are X Window System (X11) and Wayland. Knowing which system is in use helps troubleshoot, pick the right applications, and improve the graphical experience. This tutorial explains how to check which windowing system are using on Linux using C++.
On most Linux distributions, the XDG_SESSION_TYPE
environment variable stores the currently active windowing system. The following code retrieves the value of this variable using getenv
function, which is printed to the terminal:
#include <iostream>
int main()
{
char *windowingSystem = std::getenv("XDG_SESSION_TYPE");
std::cout << windowingSystem << std::endl;
return 0;
}
Output example:
x11
In our scenario, the output displays X11
, it signifies the utilization of the X11 windowing system. If the output will be wayland
, it indicates the usage of the Wayland windowing system.
Leave a Comment
Cancel reply