diff options
author | Alessio Sergi <al3hex@gmail.com> | 2013-04-03 15:41:00 +0200 |
---|---|---|
committer | Alessio Sergi <al3hex@gmail.com> | 2013-04-03 15:41:00 +0200 |
commit | 0e52348aed40be806631dffc0fd9921453b8b0b1 (patch) | |
tree | 062acbd55f09c3cb5ef5835c521af8aeefa7e198 | |
parent | 88c1cc8f7868f59f6e95419379865854e400afb9 (diff) |
Add support for local conf file
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | glances/glances.py | 7 |
3 files changed, 9 insertions, 2 deletions
@@ -119,7 +119,7 @@ The default configuration file is under: /etc/glances/glances.conf (Linux) or - /usr/local/etc/glances.conf (*BSD and OS X) + /usr/local/etc/glances/glances.conf (*BSD and OS X) To override the default configuration, you can copy the `glances.conf` file to your `$XDG_CONFIG_HOME` directory (e.g. Linux): @@ -119,7 +119,7 @@ The default configuration file is under: /etc/glances/glances.conf (Linux) or - /usr/local/etc/glances.conf (*BSD and OS X) + /usr/local/etc/glances/glances.conf (*BSD and OS X) To override the default configuration, you can copy the `glances.conf` file to your `$XDG_CONFIG_HOME` directory (e.g. Linux): diff --git a/glances/glances.py b/glances/glances.py index 25d99ee7..0a7439c0 100644 --- a/glances/glances.py +++ b/glances/glances.py @@ -197,20 +197,27 @@ class Config: Get a list of config file paths, taking into account of the OS, priority and location. + * running from source: /path/to/glances/glances/conf * Linux: ~/.config/glances, /etc/glances * BSD: ~/.config/glances, /usr/local/etc/glances * Mac: ~/Library/Application Support/glances, /usr/local/etc/glances The config file will be searched in the following order of priority: * /path/to/file (via -C flag) + * /path/to/glances/glances/conf * user's home directory (per-user settings) * /etc directory (system-wide settings) """ + base_path = os.path.dirname(os.path.abspath(__file__)) + local_path = os.path.join(base_path, 'conf', self.filename) paths = [] if self.location is not None: paths.append(self.location) + if os.path.exists(local_path): + paths.append(local_path) + if is_Linux or is_BSD: paths.append(os.path.join( os.environ.get('XDG_CONFIG_HOME') or os.path.expanduser('~/.config'), |