5dbb152a85c7b5303d898a456a4b33bd53fe78f7
[lxde/lxadmin.git] / src / common / detect_os.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 #
4 # Copyright 2010 Julien Lavergne <gilir@ubuntu.com>
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
20
21 import os
22 import platform
23
24 #Detect Linux distribution
25 os_detection = platform.dist()
26
27 #Detect session
28 session = os.environ['DESKTOP_SESSION']
29
30
31 # Set configuration location.
32 if os_detection[0] == 'Ubuntu':
33 if session == 'Lubuntu':
34 config_lxdm = '/etc/xdg/lubuntu/lxdm/lxdm.conf'
35 config_openbox_local = os.path.expanduser("~/.config/openbox/lubuntu-rc.xml")
36 else:
37 config_lxdm = '/etc/xdg/lxdm/default.conf'
38 config_openbox_local = os.path.expanduser("~/.config/openbox/lxde-rc.xml")
39 else:
40 config_lxdm = '/etc/lxdm/lxdm.conf'
41 config_openbox_local = os.path.expanduser("~/.config/openbox/lxde-rc.xml")
42
43 def get_lxdm_config():
44 return config_lxdm
45
46 def get_openbox_config():
47 return config_openbox_local