summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurie Clark-Michalek <bluepeppers@archlinux.us>2010-11-22 13:41:53 +0000
committerLaurie Clark-Michalek <bluepeppers@archlinux.us>2010-11-22 13:41:53 +0000
commit918cdeb222e4bdb936f9c21e9108877215565f2b (patch)
tree7839c288e7c12ef676779053ad6d81f8fe19a8fe
parentde5f0e186e15f8d29b3d44f54c75105732f21448 (diff)
Display modules can now be configured in the configuration file.
The configuration file show defign a list of strings refering to display classes named 'display'.
-rw-r--r--archey.new55
1 files changed, 31 insertions, 24 deletions
diff --git a/archey.new b/archey.new
index ee03679..5d2b25f 100644
--- a/archey.new
+++ b/archey.new
@@ -21,16 +21,7 @@ from time import ctime, sleep
#---------------Output---------------#
-output = [
- 'User',
- 'Uptime',
- 'WindowManager',
- 'DesktopEnvironment',
- 'Shell',
- 'Terminal',
- 'Packages',
- 'FileSystem:/home',
- ]
+
#--------------Exceptions-------------#
@@ -506,16 +497,17 @@ def main():
out = Output()
- displays = get_display_objects(output)
+ displays = get_display_objects()
out.extend(displays)
out.output()
-def get_display_objects(names):
+def get_display_objects():
"""
Returns a list of display objects, from the names in the list passed to the
function as the first argument.
"""
+ names = config.display
for raw in names:
if ':' in raw:
name, *raw_arguments = raw.split(':')
@@ -542,19 +534,34 @@ def load_config():
"""
config_dir = os.getenv('XDG_CONFIG_HOME')
sys.path.append(config_dir)
- try:
- import archey as config
- except ImportError:
- class config():
- defaults = {}
-
- def __getattr__(self, name):
- if name in self.defaults.keys():
- return self.defaults[name]
- else:
- return None
- return config
+ class _config():
+ defaults = {'display':
+ ['User',
+ 'Uptime',
+ 'WindowManager',
+ 'DesktopEnvironment',
+ 'Shell',
+ 'Terminal',
+ 'Packages',
+ 'FileSystem:/home',
+ ]
+ }
+
+ try:
+ import archey as _config
+ except ImportError:
+ _config = None
+
+ def __getattr__(self, name):
+ if hasattr(self._config, name):
+ return getattr(self._config, name)
+ elif name in self.defaults.keys():
+ return self.defaults[name]
+ else:
+ return None
+
+ return _config()
if __name__ == '__main__':