Is there any way (such as a command or environmental variable) to determine what window manager is the one actively running in the current session?
|
|
|
On Linux systems I tested environment variables
Ubuntu 16.04Unity (7)
Ubuntu 14.04Unity running with Mir
Note MIR_SERVER_NAME is also set
Unity running without Mir
XFCE
Ubuntu 12.04KDE
Unity 3d
Unity 2d
Gnome
Gnome Classic
Gnome Classic (no effects)
Other Ubuntu based distributionsMint 13 (Cinnamon)
Mint 16 (KDE edition)
Mint 17 (Cinnamon)
Lubuntu 12.04
Wasta 14.04
Wasta 14.04 using Gnome desktop.
|
|||||||||||||||||||||
|
|
None of the above actually worked for me, I just wanted to know whether I had Gnome running as my current desktop session. This is what worked, open a terminal
(to check which flavor or version I had installed on my UBUNTU machine)
(launches which desktop session/desktop environment currently in use)
(to find out which version of gnome is installed) |
||||
|
|
|
If you have
will show you the name of the window manager. If you don't have
Note,
On my Ubuntu 11.10 / Linux 3.0.0-14-generic #23-Ubuntu x86_64 / metacity 2.34.1 system, the first line of output from On a fresh Ubuntu 15.10 install of |
|||||||||||||||||||||
|
|
This is sort of possible with dbus and the Accounts Service (both by default in Ubuntu).
Worth noting that I've tested this with logging in through lightdm (that is the graphical login screen) , it did detect a classic desktop like blackbox , and obviously detects Unity. I suspect this is a value of what user selects on the login screen as session, that's why it's a bit easier to use that checking for processes |
|||||
|
|
|||||||||
|
|
I found
|
|||
|
|
|
The following script resulted as the best answer to a similar question I posted over at unix.se. It also works great with Unity and LXDE.
|
||||
|
|
|
In the terminal type XDG_CURRENT_DESKTOP - Tells you what Windows Manager you are using GDMSESSION - Tells you what option you selected from the lightdm greeter to login. To use them, go to the terminal and type:
(Will output for example 'unity' if you are using Unity) or
(Will output for example 'ubuntu' if you selected ubuntu in the login or 'ubuntu-2d' if you selected that one in the login.) You have others if you look closer at the output of Since what you are looking for is the name of what Window Manager is in usem the only way I see how to get this is by looking in the process list. To do this there is a command called
To look for other types, just change the word |
|||||||||
|
|
I've been testing also with KDE and my conclusion is: a) Graphical way, with HardInfo: the answer is normally in "Operating System" > "Desktop Environment", but if not you can look to "Environment variables". HardInfo is ready with all the tested distros, except the one with KDE, but it can be easily and quickly installed (only 2 packages in Linux Mint 13). b) Command line, with this command: |
|||||
|
|
I can only think of checking for known window managers in the running processes. There used to be a key in gconf that was set to the preferred window manager, but its deprecated since Gnome 2.12. So, if this is for a programming purpose, I suggest you to research for all the linux window managers; some popular are:
You would have to run a check for each with the command I am not 100% sure if Gnome Shell is considered a window manager; the rest of the window managers I got from a list in the EDIT: Well @Anarci 's comment seems to be more accurate. In my case it did show |
|||||||||
|
protected by Community♦ Aug 9 '17 at 2:02
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?