Skip to content

Respect XDG_CONFIG_HOME on macOS when resolving config.toml #176

Description

@Wolfsrudel

Problem

On macOS, abtop does not respect XDG_CONFIG_HOME when resolving its configuration file.

The documentation says the configuration is stored at:

~/.config/abtop/config.toml

However, abtop currently resolves the path with:

dirs::config_dir().map(|dir| dir.join("abtop").join("config.toml"))

On macOS, dirs::config_dir() returns:

~/Library/Application Support

Consequently, abtop reads and writes:

~/Library/Application Support/abtop/config.toml

This happens even when the user has explicitly configured:

export XDG_CONFIG_HOME="$HOME/.config"

As a result, $XDG_CONFIG_HOME/abtop/config.toml is silently ignored. This is confusing because the documented configuration file exists, but settings such as theme = "btop" have no effect.

Requested behavior

When XDG_CONFIG_HOME is set and non-empty, abtop should read and write:

$XDG_CONFIG_HOME/abtop/config.toml

For example:

export XDG_CONFIG_HOME="$HOME/.config"

should make abtop use:

~/.config/abtop/config.toml

When XDG_CONFIG_HOME is unset or empty, abtop can retain its current platform-specific fallback:

~/Library/Application Support/abtop/config.toml

Suggested resolution order

  1. $XDG_CONFIG_HOME/abtop/config.toml when XDG_CONFIG_HOME is set and non-empty.
  2. dirs::config_dir()/abtop/config.toml as the platform-specific fallback.

For example:

fn config_path() -> Option<PathBuf> {
    std::env::var_os("XDG_CONFIG_HOME")
        .filter(|value| !value.is_empty())
        .map(PathBuf::from)
        .or_else(dirs::config_dir)
        .map(|dir| dir.join("abtop").join("config.toml"))
}

The same resolved path should be used for both loading and saving configuration.

Steps to reproduce

  1. On macOS, set:

    export XDG_CONFIG_HOME="$HOME/.config"
  2. Create ~/.config/abtop/config.toml with:

    theme = "btop"
  3. Create or retain ~/Library/Application Support/abtop/config.toml with:

    theme = "catppuccin"
  4. Start abtop.

Actual behavior

abtop uses the configuration under ~/Library/Application Support/abtop/ and displays the Catppuccin theme.

The file under $XDG_CONFIG_HOME/abtop/ is ignored.

Expected behavior

Because XDG_CONFIG_HOME is explicitly set, abtop should use $XDG_CONFIG_HOME/abtop/config.toml and display the btop theme.

Environment

  • abtop: 0.5.5
  • Operating system: macOS
  • Installation method: release shell installer
  • Relevant dependency: dirs 6.0.0

Documentation

The configuration documentation should also describe the lookup order and mention the macOS fallback path.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions