diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2012-02-23 21:17:38 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2012-02-23 21:17:38 +0000 |
commit | 1dba891b3ff51a2172a431f732b8d0e3a2586f50 (patch) | |
tree | e2e7a34805283ee038ffd335aed46b97edd2c3ee /alot | |
parent | 8b3a8f2b67f5518b8552ba5f3ca58b1dcd821000 (diff) |
read themes from themes_dir
this introduces two new config keys:
theme: the string identifier of the theme file to use
theme_dir: where to look for this file.
theme_dir defaults to ~/.config/alot.themes
Diffstat (limited to 'alot')
-rw-r--r-- | alot/defaults/alot.rc.spec | 6 | ||||
-rw-r--r-- | alot/settings.py | 17 |
2 files changed, 23 insertions, 0 deletions
diff --git a/alot/defaults/alot.rc.spec b/alot/defaults/alot.rc.spec index 3d277437..296d58f0 100644 --- a/alot/defaults/alot.rc.spec +++ b/alot/defaults/alot.rc.spec @@ -16,6 +16,12 @@ tabwidth = integer(default=8) # It will be used if you give `compose --template` a filename without a path prefix. template_dir = string(default='$XDG_CONFIG_HOME/alot/templates') +# directory containing theme files +themes_dir = string(default=None) + +# name of the theme to use +theme = string(default=None) + # fill threadline with message content display_content_in_threadline = boolean(default=False) diff --git a/alot/settings.py b/alot/settings.py index 919915b0..b95595d7 100644 --- a/alot/settings.py +++ b/alot/settings.py @@ -162,6 +162,23 @@ class SettingsManager(object): newbindings = newconfig['bindings'] if isinstance(newbindings, Section): self._bindings.merge(newbindings) + # themes + themestring = newconfig['theme'] + themes_dir = self._config.get('themes_dir') + if themes_dir: + themes_dir = os.path.expanduser(themes_dir) + else: + themes_dir = os.path.join(os.environ.get('XDG_CONFIG_HOME', + os.path.expanduser('~/.config')), 'alot', 'themes') + logging.debug(themes_dir) + + if themestring: + if not os.path.isdir(themes_dir): + err_msg = 'cannot find theme %s: themes_dir %s is missing' + raise ConfigError(err_msg % (themestring, themes_dir)) + else: + theme_path = os.path.join(themes_dir, themestring) + self._theme = Theme(theme_path) self._accounts = self._parse_accounts(self._config) self._accountmap = self._account_table(self._accounts) |