detect_os: Add option to retrieve su command.
[lxde/lxadmin.git] / src / common / detect_os.py
CommitLineData
3208b7b4
JL
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
21import os
22import platform
23
24#Detect Linux distribution
25os_detection = platform.dist()
26
27#Detect session
28session = os.environ['DESKTOP_SESSION']
29
cac00936
JL
30
31# Set configuration location.
32if 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")
be255f2e 36 command_su = "gksu"
3208b7b4 37 else:
cac00936
JL
38 config_lxdm = '/etc/xdg/lxdm/default.conf'
39 config_openbox_local = os.path.expanduser("~/.config/openbox/lxde-rc.xml")
be255f2e 40 command_su = "gksu"
cac00936
JL
41else:
42 config_lxdm = '/etc/lxdm/lxdm.conf'
43 config_openbox_local = os.path.expanduser("~/.config/openbox/lxde-rc.xml")
be255f2e 44 command_su = "su-to-root -X -c"
3208b7b4 45
cac00936 46def get_lxdm_config():
3208b7b4 47 return config_lxdm
cac00936
JL
48
49def get_openbox_config():
50 return config_openbox_local
be255f2e
JL
51
52def get_command_su():
53 return command_su