# HG changeset patch # User paulb # Date 1188253711 0 # Node ID 95b9e1559d105a2dad70f2d39c8c6f96c6b244c1 # Parent 276db7d814a5bdf69e574f41f05f79a282ef907b [project @ 2007-08-27 22:28:31 by paulb] Updated release notes. Improved XFCE detection with DISPLAY variable definition if necessary. diff -r 276db7d814a5 -r 95b9e1559d10 README.txt --- a/README.txt Mon Aug 27 19:34:27 2007 +0000 +++ b/README.txt Mon Aug 27 22:28:31 2007 +0000 @@ -51,7 +51,7 @@ New in desktop 0.2.4 (Changes since desktop 0.2.3) -------------------------------------------------- - * Added XFCE support. + * Added XFCE support (with advice from Miki Tebeka). * Added Ubuntu Feisty (7.04) package support. New in desktop 0.2.3 (Changes since desktop 0.2.2) diff -r 276db7d814a5 -r 95b9e1559d10 desktop.py --- a/desktop.py Mon Aug 27 19:34:27 2007 +0000 +++ b/desktop.py Mon Aug 27 22:28:31 2007 +0000 @@ -112,6 +112,24 @@ import commands +# Private functions. + +def _is_xfce(): + + "Return whether XFCE is in use." + + # XFCE detection involves testing the output of a program. + + try: + if not os.environ.get("DISPLAY", "").strip(): + vars = "DISPLAY=:0.0 " + else: + vars = "" + return _readfrom(vars + "xprop -root _DT_SAVE_MODE", shell=1).endswith(' = "xfce4"') + + except OSError: + return 0 + # Introspection functions. def get_desktop(): @@ -131,14 +149,8 @@ return "Mac OS X" elif hasattr(os, "startfile"): return "Windows" - - # XFCE detection involves testing the output of a program. - - try: - if _readfrom("xprop -root _DT_SAVE_MODE", shell=0).endswith(' = "xfce4"'): - return "XFCE" - except OSError: - pass + elif _is_xfce(): + return "XFCE" # XFCE runs on X11, so we have to test for X11 last.