Add a detect_os module to detect configuration files on the current system.
authorJulien Lavergne <julien.lavergne@gmail.com>
Sat, 19 Jun 2010 15:22:03 +0000 (17:22 +0200)
committerJulien Lavergne <julien.lavergne@gmail.com>
Sat, 19 Jun 2010 15:22:03 +0000 (17:22 +0200)
Support only lxdm and Ubuntu/Lubuntu

src/common/Makefile.am
src/common/detect_os.py [new file with mode: 0644]

index 6cbe8eb..df2e295 100644 (file)
@@ -2,11 +2,11 @@ SUBDIRS =
 
 commondir = $(pythondir)/lxadmin
 common_PYTHON = \
+       detect_os.py \
        defs.py
        
 CLEANFILES = \
-       defs.py \
-       $(BUILT_SOURCES)
+       defs.py
        
 DISTCLEANFILES = \
        $(CLEANFILES)
diff --git a/src/common/detect_os.py b/src/common/detect_os.py
new file mode 100644 (file)
index 0000000..2e91786
--- /dev/null
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#       
+#       Copyright 2010 Julien Lavergne <gilir@ubuntu.com>
+#       
+#       This program is free software; you can redistribute it and/or modify
+#       it under the terms of the GNU General Public License as published by
+#       the Free Software Foundation; either version 2 of the License, or
+#       (at your option) any later version.
+#       
+#       This program is distributed in the hope that it will be useful,
+#       but WITHOUT ANY WARRANTY; without even the implied warranty of
+#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#       GNU General Public License for more details.
+#       
+#       You should have received a copy of the GNU General Public License
+#       along with this program; if not, write to the Free Software
+#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+#       MA 02110-1301, USA.
+
+import os
+import platform
+
+#Detect Linux distribution
+os_detection = platform.dist()
+
+#Detect session
+session = os.environ['DESKTOP_SESSION']
+
+def get_lxdm_config():
+    if os_detection[0] == 'Ubuntu':
+        if session == 'Lubuntu':
+            config_lxdm = '/etc/xdg/lubuntu/lxdm/lxdm.conf'
+        else:
+            config_lxdm = '/etc/xdg/lxdm/default.conf'
+    else:
+        config_lxdm = '/etc/lxdm/lxdm.conf'
+
+    return config_lxdm