1

I want to see Display Manager name (Gnome, KDE etc.) via python or bash script. Is there any command for it as uname? (I try fedora and Debian)

Runium
  • 28,133
  • 5
  • 50
  • 71
Gyhot
  • 267
  • 2
  • 4
  • 9
  • 2
    "GUI" is a bit vague. Are you interested in your desktop environment, your window manager or your display manager? For finding out the session manager on Debian, for example, you can use `readlink /etc/alternatives/x-session-manager` but this is definitely not portable (doesn't work on Fedora). – Joseph R. May 22 '13 at 14:01
  • 1
    You can try [`xwininfo -id $(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')`][1] for the current window. [1]: http://askubuntu.com/a/20534/10371 – l0b0 May 22 '13 at 14:03
  • How do you plan to select the application if you don't know it's name? Is it a GUI that Python or Bash would've started up initially? `xwininfo` can give you information about the various GUI's running. – slm May 22 '13 at 14:03
  • I want to install a package according to the type of GUI via script. My script must know the GUI name. Thus I asked the question. – Gyhot May 22 '13 at 14:19
  • I wrote wrong. My question is relevant with Display Manager or Desktop Manager. – Gyhot May 22 '13 at 14:30

2 Answers2

2

You may probably check the environment variable named DESKTOP_SESSION.

eppesuig
  • 3,208
  • 1
  • 14
  • 13
  • This seems to work well enough. Interestingly, though, I tried it in a root terminal (after `su`) and it was unset. – Joseph R. May 22 '13 at 14:29
  • 1
    It reports `default` on my system. Not very helpful. – Marco May 22 '13 at 14:30
  • @JosephR. that is probably because the `root` user has not started any Desktop Session, it is your user who has launched it. – terdon May 22 '13 at 16:43
  • You're right. I was substituting my user's environment with `root`'s (via `su -`) – Joseph R. May 22 '13 at 16:46
  • @Marco it should contain the desktop name choosen by the user at login time. If the content is `default`, then I think, it gets the first one in `/usr/share/xsessions`. – eppesuig May 23 '13 at 08:04
0

As @eppesuig has said, the environment variable DESKTOP_SESSION may tell you the currently running session.

But that doesn't mean it is the only – or even normal – Desktop environment in use on that system. I usually use GNOME3, but sometimes I boot into KDE or Enlightenment.

If the point of this is to select a desktop-specific GUI package for installation, this really should be used to suggest a default option rather than making a firm decision. If I happened to be running KDE when I installed your app, I would be disappointed to discover I had only installed a QT interface if a GTK interface was available.

Anthon
  • 78,313
  • 42
  • 165
  • 222
Chris Throup
  • 121
  • 4