Is there an environment variable that is set for Unity?

My script needs to be able to detect if the Unity is being used on top of the Gnome DE. The only other way I can think of is basically seeing if the config file is there.


Solution 1:

Ubuntu 11.10

  1. Ubuntu session (compiz/unity)

    DESKTOP_SESSION=ubuntu
    GDMSESSION=ubuntu
    XDG_CURRENT_DESKTOP=Unity
    
  2. Ubuntu 2D session (metacity):

    DESKTOP_SESSION=ubuntu-2d
    GDMSESSION=ubuntu-2d
    XDG_CURRENT_DESKTOP=Unity
    
  3. Gnome session (gnome-shell):

    DESKTOP_SESSION=gnome-shell
    GDMSESSION=gnome-shell
    XDG_CURRENT_DESKTOP=GNOME
    
  4. Gnome Classic session (metacity):

    DESKTOP_SESSION=gnome-classic
    GDMSESSION=gnome-classic
    XDG_CURRENT_DESKTOP=GNOME
    
  5. Gnome Classic no effects session (metacity):

    DESKTOP_SESSION=gnome-fallback
    GDMSESSION=gnome-fallback
    XDG_CURRENT_DESKTOP=GNOME
    

Ubuntu 11.04

  1. Ubuntu session (compiz/unity):

    DESKTOP_SESSION=gnome
    GDMSESSION=gnome
    
  2. Ubuntu Classic session (compiz):

    DESKTOP_SESSION=gnome-classic
    GDMSESSION=gnome-classic
    
  3. Ubuntu Classic no effects session (metacity):

    DESKTOP_SESSION=gnome-2d
    GDMSESSION=gnome-2d