Merging upstream version 0.5.1.
[debian/lxappearance.git] / debian / apport / source_lxappearance.py
CommitLineData
0d34888c
DB
1"""
2 Copyright (c) 2010 Julien Lavergne <gilir@ubuntu.com>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17"""
18
19import os
20import apport.hookutils
21
22#Detect session
23session = os.environ['DESKTOP_SESSION']
24
25#Set location of various configuration files
26system_conf = "/etc/xdg/lxsession/"
27home_conf = os.path.expanduser("~/.config/lxsession/")
28gtkrc_conf = os.path.expanduser("~/.gtkrc-2.0")
29icons_default_conf = os.path.expanduser("~.icons/default/index.theme")
30
31#Set description for each file reported by apport
32report_icons_default = "Icons_Default"
33report_gtkrc = "gtkrc_Config"
34if session:
35 report_config_system = "Config_System_" + session
36 report_config_home = "Config_Home_" + session
37
38def add_info(report):
39 if not session:
40 report[report_gtkrc] = apport.hookutils.read_file(gtkrc_conf)
41 report[report_icons_default] = apport.hookutils.read_file(icons_default_conf)
42 elif os.path.exists(os.path.join(home_conf,session,"desktop.conf")):
43 # If a config file exist in HOME, report it instead of the system one.
44 report[report_config_home] = apport.hookutils.read_file(os.path.join(home_conf,session,"desktop.conf"))
45 if os.path.exists(icons_default_conf):
46 report[report_icons_default] = apport.hookutils.read_file(icons_default_conf)
47 else:
48 report[report_icons_default] = "No icons theme configured by default"
49 else:
50 report[report_config_system] = apport.hookutils.read_file(os.path.join(system_conf,session,"desktop.conf"))
51 if os.path.exists(icons_default_conf):
52 report[report_icons_default] = apport.hookutils.read_file(icons_default_conf)
53 else:
54 report[report_icons_default] = "No icons theme configured by default"