Skip to content

Commit

Permalink
Merge pull request #3106 from almkuznetsov/config-dir
Browse files Browse the repository at this point in the history
default_config_dir: Fix config path to include glances/ directory
  • Loading branch information
nicolargo authored Feb 19, 2025
2 parents 0c6c488 + bafe0e2 commit c00383f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Location
You can place your ``glances.conf`` file in the following locations:

==================== =============================================================
``Linux``, ``SunOS`` ~/.config/glances/, /etc/glances/, /usr/share/docs/glances/
``*BSD`` ~/.config/glances/, /usr/local/etc/glances/, /usr/share/docs/glances/
``macOS`` ~/.config/glances/, ~/Library/Application Support/glances/, /usr/local/etc/glances/, /usr/share/docs/glances/
``Linux``, ``SunOS`` ~/.config/glances/, /etc/glances/, /usr/share/doc/glances/
``*BSD`` ~/.config/glances/, /usr/local/etc/glances/, /usr/share/doc/glances/
``macOS`` ~/.config/glances/, ~/Library/Application Support/glances/, /usr/local/etc/glances/, /usr/share/doc/glances/
``Windows`` %APPDATA%\\glances\\glances.conf
``All`` + <venv_root_folder>/share/doc/glances/
==================== =============================================================
Expand Down
6 changes: 3 additions & 3 deletions docs/man/glances.1
Original file line number Diff line number Diff line change
Expand Up @@ -565,19 +565,19 @@ l|l.
T{
\fBLinux\fP, \fBSunOS\fP
T} T{
~/.config/glances/, /etc/glances/, /usr/share/docs/glances/
~/.config/glances/, /etc/glances/, /usr/share/doc/glances/
T}
_
T{
\fB*BSD\fP
T} T{
~/.config/glances/, /usr/local/etc/glances/, /usr/share/docs/glances/
~/.config/glances/, /usr/local/etc/glances/, /usr/share/doc/glances/
T}
_
T{
\fBmacOS\fP
T} T{
~/.config/glances/, ~/Library/Application Support/glances/, /usr/local/etc/glances/, /usr/share/docs/glances/
~/.config/glances/, ~/Library/Application Support/glances/, /usr/local/etc/glances/, /usr/share/doc/glances/
T}
_
T{
Expand Down
18 changes: 10 additions & 8 deletions glances/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,20 @@ def default_config_dir():
- Linux, SunOS, *BSD, macOS: /usr/share/doc (as defined in the setup.py files)
- Windows: %APPDATA%\glances
"""
path = []
# Add venv path (solve issue #2803)
if in_virtualenv():
path.append(os.path.join(sys.prefix, 'share', 'doc', 'glances'))
paths = []

# Add others system path
# Add system path
if LINUX or SUNOS or BSD or MACOS:
path.append('/usr/share/doc')
paths.append(os.path.join(sys.prefix, 'share', 'doc'))
else:
path.append(os.environ.get('APPDATA'))
paths.append(os.environ.get('APPDATA'))

return path
# If we are in venv (issue #2803), sys.prefix != sys.base_prefix and we
# already added venv path with sys.prefix. Add base_prefix path too
if in_virtualenv():
paths.append(os.path.join(sys.base_prefix, 'share', 'doc'))

return [os.path.join(path, 'glances') if path is not None else '' for path in paths]


def in_virtualenv():
Expand Down

0 comments on commit c00383f

Please sign in to comment.