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?
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?
If you have
wmctrl
installed, the first line of output from commandwill show you the name of the window manager. If you don't have
wmctrl
installed, use the following command to install it:Note,
man wmctrl
(that is, theman
page forwmctrl
) says in part: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
wmctrl -m
was:Name: Metacity
while
echo $DESKTOP_SESSION
showedubuntu-2d
andecho $XDG_CURRENT_DESKTOP
showedUnity
.On a fresh Ubuntu 15.10 install of
Ubuntu desktop
software on an old laptop, the first line of output fromwmctrl -m
was:Name: Compiz
while the
DESKTOP_SESSION
andXDG_CURRENT_DESKTOP
values wereubuntu
andUnity
On Linux systems I tested environment variables
XDG_CURRENT_DESKTOP
andGDMSESSION
and got the following results.Ubuntu 18.04 and 20.04 (Ubuntu on GNOME)
XDG_CURRENT_DESKTOP=ubuntu:GNOME
GDMSESSION=ubuntu
Ubuntu 18.04 (Ubuntu on Wayland)
XDG_CURRENT_DESKTOP=ubuntu:GNOME
GDMSESSION=ubuntu-wayland
Ubuntu 16.04
Unity (7)
XDG_CURRENT_DESKTOP=Unity
GDMSESSION=ubuntu
Ubuntu 14.04
Unity running with Mir
XDG_CURRENT_DESKTOP=Unity
GDMSESSION=ubuntu
Note
MIR_SERVER_NAME
is also setMIR_SERVER_NAME=session-$NUMBER
Unity running without Mir
XDG_CURRENT_DESKTOP=Unity
GDMSESSION=ubuntu
XFCE
XDG_CURRENT_DESKTOP=XFCE
GDMSESSION=xfce
Ubuntu 12.04
KDE
XDG_CURRENT_DESKTOP=
GDMSESSION=kde-plasma
Unity 3D
XDG_CURRENT_DESKTOP=Unity
GDMSESSION=ubuntu
Unity 2D
XDG_CURRENT_DESKTOP=Unity
GDMSESSION=ubuntu-2d
Gnome
XDG_CURRENT_DESKTOP=GNOME
GDMSESSION=gnome-shell
Gnome Classic
XDG_CURRENT_DESKTOP=GNOME
GDMSESSION=gnome-classic
Gnome Classic (no effects)
XDG_CURRENT_DESKTOP=GNOME
GDMSESSION=gnome-fallback
Other Ubuntu based distributions
Mint 13 (Cinnamon)
XDG_CURRENT_DESKTOP=GNOME
GDMSESSION=cinnamon
Mint 16 (KDE edition)
XDG_CURRENT_DESKTOP=KDE
GDMSESSION=default
Mint 17 (Cinnamon)
XDG_CURRENT_DESKTOP=X-Cinnamon
GDMSESSION=default
Lubuntu 12.04
XDG_CURRENT_DESKTOP=LXDE
GDMSESSION=Lubuntu
Wasta 14.04 / 18.04
XDG_CURRENT_DESKTOP=X-Cinnamon
GDMSESSION=cinnamon
Wasta 14.04 using Gnome desktop.
XDG_CURRENT_DESKTOP=GNOME
GDMSESSION=gnome
Ubuntu Mate 18.04
XDG_CURRENT_DESKTOP=MATE
GDMSESSION=mate
Xubuntu 18.04
XDG_CURRENT_DESKTOP=XFCE
GDMSESSION=xubuntu
Kali Linux kali-rolling 2020.2
XDG_CURRENT_DESKTOP=GNOME
GDMSESSION=lightdm-xsession
In the terminal type
env
to see all environment variables. Some of them are:XDG_CURRENT_DESKTOP - Tells you what desktop environment 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
env
like DESKTOP_SESSION and COMPIZ_CONFIG_PROFILESince what you are looking for is the name of what Window Manager is in use, the only way I see how to get this is by looking in the process list. To do this there is a command called
pgrep
( Wikipedia ). I did the following to get the name since the parameter -l adds the process ID:pgrep -l compiz |cut -d " " -f2
since the process is running by the same user there is no need to prefix the sudo part. You can then use this to create a script that does an action based on the Window Manager.To look for other types, just change the word
compiz
to another likemutter
,kwin
, etc..I found
pstree
to be a big help.Installation
output
This is what I got.
Just two cents.
Or in one line:
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:
ps -A | egrep -i "gnome|kde|mate|cinnamon|lx|xfce|jwm"
. The item that appears in more lines should be the answer (if there is a draw the item with "session" should be the solution).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)
This question is 9 years old, but still topical. On my Ubuntu 20.04.2 LTS, I get :
wmctrl -m: GNOME Shell
inxi -Sxx: Desktop = Gnome 3.36.4; wm = gnome-shell; dm = GDM3 3.36.3
gnome-shell -- version: 3.36.4
env:GDM_SESSION : ubuntu ; DESKTOP_SESSION: ubuntu ; XDG_CURRENT_DESKTOP: ubuntu:GNOME
BUT
xprop... (from ruario): _NET_WM_NAME : GNOME Shell ; _GNOME_WM_KEYBINDINGS : Mutter, GNOME Shell ; _MUTTER_VERSION : 3.36.7
and neofetch: de = GNONE ; wm = Mutter
I deduce from this (but not very sure): GNOME is the desktop manager and GNOME Shell the window manager (Mutter must be a trace of my previous LTS versions 16.04 et 18.04).