]> git.phdru.name Git - xsetbg.git/blob - xsetbg_conf.py
Remove outdated __copyright__
[xsetbg.git] / xsetbg_conf.py
1 #! /usr/bin/env python
2 """XSetBg config
3
4 """
5
6 import os
7 from ConfigParser import SafeConfigParser
8
9 __all__ = ['xsetbg_conf']
10
11 config_dirs = []
12 if 'XDG_CONFIG_HOME' in os.environ:
13     config_dirs.append(os.environ['XDG_CONFIG_HOME'])
14 if 'XDG_CONFIG_DIRS' in os.environ:
15     config_dirs.extend(os.environ['XDG_CONFIG_DIRS'].split(':'))
16 home_config = os.path.expanduser('~/.config')
17 if home_config not in config_dirs:
18     config_dirs.append(home_config)
19
20 xsetbg_dir = os.path.dirname(os.path.abspath(__file__))
21 config_dirs.append(xsetbg_dir)
22
23 for d in config_dirs:
24     xsetbg_conf_file = os.path.join(d, 'xsetbg.conf')
25     if os.path.exists(xsetbg_conf_file):
26         xsetbg_conf = SafeConfigParser()
27         xsetbg_conf.read(xsetbg_conf_file)
28         break
29 else:
30     raise RuntimeError("Cannot find xsetbg.conf; searched %s", config_dirs)
31
32 if __name__ == '__main__':
33     print "Config dirs:", config_dirs
34     print "Config file:", xsetbg_conf_file