How to determine which window manager is running

317,790

Solution 1

If you have wmctrl installed, the first line of output from command

wmctrl -m

will show you the name of the window manager. If you don't have wmctrl installed, use the following command to install it:

sudo apt-get install wmctrl

Note, man wmctrl (that is, the man page for wmctrl) says in part:

-m Display information about the window manager ...

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 showed ubuntu-2d and echo $XDG_CURRENT_DESKTOP showed Unity.

On a fresh Ubuntu 15.10 install of Ubuntu desktop software on an old laptop, the first line of output from wmctrl -m was: Name: Compiz
while the DESKTOP_SESSION and XDG_CURRENT_DESKTOP values were ubuntu and Unity

Solution 2

On Linux systems I tested environment variables XDG_CURRENT_DESKTOP and GDMSESSION and got the following results.

You can use this line to get the output:

printf 'Desktop: %s\nSession: %s\n' "$XDG_CURRENT_DESKTOP" "$GDMSESSION"

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 set

  • MIR_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

Solution 3

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:

echo $XDG_CURRENT_DESKTOP

(Will output for example 'unity' if you are using Unity)

or

echo $GDMSESSION  

(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_PROFILE

Since 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 like mutter, kwin, etc..

Solution 4

I found pstree to be a big help.

Installation

sudo apt-get install pstree

output

This is what I got.

 ├─lightdm─┬─Xorg───2*[{Xorg}]
 │         ├─lightdm─┬─gnome-session─┬─bluetooth-apple───2*[{bluetooth-apple}]
 │         │         │               ├─compiz─┬─sh───gtk-window-deco───2*[{gtk-window-deco}]
 │         │         │               │        └─5*[{compiz}]
 │         │         │               ├─deja-dup-monito───2*[{deja-dup-monito}]
 │         │         │               ├─gnome-fallback-───2*[{gnome-fallback-}]
 │         │         │               ├─gnome-screensav───2*[{gnome-screensav}]
 │         │         │               ├─gnome-settings-───2*[{gnome-settings-}]
 │         │         │               ├─nautilus───2*[{nautilus}]
 │         │         │               ├─nm-applet───2*[{nm-applet}]
 │         │         │               ├─polkit-gnome-au───2*[{polkit-gnome-au}]
 │         │         │               ├─ssh-agent
 │         │         │               ├─telepathy-indic───2*[{telepathy-indic}]
 │         │         │               ├─update-notifier───2*[{update-notifier}]
 │         │         │               ├─vino-server───2*[{vino-server}]
 │         │         │               ├─zeitgeist-datah───{zeitgeist-datah}
 │         │         │               └─3*[{gnome-session}]
 │         │         └─{lightdm}
 │         └─2*[{lightdm}]

Solution 5

xprop -id $(xprop -root -notype | awk '$1=="_NET_SUPPORTING_WM_CHECK:"{print $5}') -notype -f _NET_WM_NAME 8t 
Share:
317,790

Related videos on Youtube

Anonymous
Author by

Anonymous

I like Ubuntu. :)

Updated on September 18, 2022

Comments

  • Anonymous
    Anonymous over 1 year

    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?

  • Anonymous
    Anonymous over 12 years
    Those just tell me the session name and desktop environment. Example it says "GNOME" which is a desktop environment that can use Metacity, Mutter, Compiz or other window managers. It says "gnome-classic" which is a session name, there is no such window manager with that name.
  • Luis Alvarado
    Luis Alvarado over 12 years
    There you go. Found a command that can help with the process list. pgrep. Got to that part, at least it shows you the name of the window manager if found. Trying to check if I can add all of them together there. Your question is very good since Ubuntu 11.10 confuses a bit by using Compiz (Or mutter if when Gnome 3.x) so would be nice to point out the actual Window Manager that is used in Unity.
  • 67hz
    67hz over 11 years
    Mint 13 (Cinnamon): XDG_CURRENT_DESKTOP=GNOME, GDMSESSION=cinnamon
  • 67hz
    67hz over 11 years
    Lubuntu 12.04: XDG_CURRENT_DESKTOP=LXDE, GDMSESSION=Lubuntu
  • macrobook
    macrobook over 11 years
    What about $DESKTOP_SESSION ? As a backup solution :)
  • Robert Siemer
    Robert Siemer about 10 years
    What if I don’t use GDM?
  • Sridhar Sarnobat
    Sridhar Sarnobat about 10 years
    Unfortunately this doesn't work over ssh even if X11 is enabled.
  • Louis Matthijssen
    Louis Matthijssen almost 10 years
    Can you explain how this works? Also, I think you' re missing a ) at the end.
  • cprn
    cprn almost 10 years
    @LouisMatthijssen 1. xprop -root -notype displays all of the root window's properties (and omits types for easier parsing), the output is send to awk via pipe; 2. awk instruction $1=="_NET[blah]CK:"{print $5}' compares first column of each row of the input it got through the pipe with a given string and if it finds the match it runs the code in brackets which prints the fifth column from this row - just so happens (entirely by accident, I bet) to be the ID of the "_NET_SUPPORTING_WM_CHECK" atom; 3. this ID is then used again to get the properties of the Windows Manager with xprop -id
  • Robert Siemer
    Robert Siemer about 9 years
    And further it doesn’t answer what window manager I use!
  • michael
    michael about 9 years
    @Sridhar-Sarnobat on ubuntu 15.04, running ssh -Y {host} 'wmctrl -m' does return some values (e.g., "Name: Compiz", and several N/A's), but it makes sense that ssh would have limited info about the window manager.
  • AmazeCPK
    AmazeCPK over 8 years
    on debian running cinnamon, this does not work. output of wmctrl -m is Name: Mutter(Muffin) while $XDG_CURRENT_DESKTOP=X-Cinnamon
  • Xen2050
    Xen2050 almost 8 years
    XFCE also has several gnome-... processes (and a kde hit with kdevtmpfs)
  • David
    David almost 8 years
    On Xubuntu Wily, running Window Maker 0.95.6 - wmctrl reports N/A for all entries. GDMSESSION is set to wmaker-common but XDG_CURRENT_DESKTOP isnt set at all.
  • James Waldby - jwpat7
    James Waldby - jwpat7 almost 8 years
    @Mei, do you have Window Maker running on any other systems you can compare? Also, do either of wmctrl -d (List all desktops managed by the window manager) or wmctrl -l (List the windows being managed by the window manager) work ok on Xubuntu Wily with Window Maker?
  • Ken Sharp
    Ken Sharp about 6 years
    $XDG_CURRENT_DESKTOP is the current desktop environment, NOT the window manager.
  • Bruce Adams
    Bruce Adams almost 6 years
    Note to wanderers from outside Ubuntu. On RedHat wmctrl is available from the nux-dextop repo (see unix.stackexchange.com/questions/447999/…)
  • jc__
    jc__ about 5 years
    this got me there with my custom buildroot system.
  • opinion_no9
    opinion_no9 over 4 years
    this exactly answers the question! The only answer to the question I found.
  • AlexOnLinux
    AlexOnLinux almost 4 years
    ls /usr/bin/*session showed me what was installed
  • PatS
    PatS over 3 years
    @SridharSarnobat, the XServer runs on the local system so you don't need to ssh to it. If you are running Windows (no Xserver) then ssh'ing into a remote server your connection will not likely be associated with a display.
  • hildred
    hildred over 3 years
    Does not detect ratpoision but got me headed in the right direction
  • Levente
    Levente about 3 years
    That shows how confusing all the content and conclusions are in this entire thread. Your window manager is Mutter, as pointed out very helpfully and accurately by neofetch. (I get Mutter as well on a new install of 20.04, if that helps.)
  • Timo
    Timo about 3 years
    The last line says:Window manager's "showing the desktop" mode: OFF. What does it mean?
  • James Waldby - jwpat7
    James Waldby - jwpat7 almost 3 years
    @Timo Per _NET_SHOWING_DESKTOP entry in "Extended Window Manager Hints" at freedesktop.org, if that were on, windows would be hidden, with only the desktop background displayed and focused. Maybe not an everyday need.
  • Manuel Jordan
    Manuel Jordan over 2 years
    Really $DESKTOP_SESSION returns the Window Manager - that is the correct answer. - for more details see - askubuntu.com/a/125072/970554 - and $XDG_CURRENT_DESKTOP returns the Desktop Environment
  • Manuel Jordan
    Manuel Jordan over 2 years
    How a friendly clarification: Really $DESKTOP_SESSION returns the Window Manager - that is the correct answer. - for more details see - askubuntu.com/a/125072/970554 - and $XDG_CURRENT_DESKTOP returns the Desktop Environment
  • Manuel Jordan
    Manuel Jordan over 2 years
    @RobertSiemer in someway the answer is correct - it seems that GDMSESSION returns the Window Manager - of course we are right about that $XDG_CURRENT_DESKTOP returns the Desktop Environment
  • Manuel Jordan
    Manuel Jordan over 2 years
    it seems that GDMSESSION returns the Window Manager - and of course $XDG_CURRENT_DESKTOP returns the Desktop Environment