Skip to content

Check for configuration file at /etc/polybar/config as a fallback #2016

@samueloph

Description

@samueloph

Coming from the Debian packaging of polybar.

This feature request is for a little bit more than what the tittle says...

Polybar currently has the following precedence for loading the config file:

polybar/src/main.cpp

Lines 107 to 115 in fab8437

if (cli->has("config")) {
confpath = cli->get("config");
} else if (env_util::has("XDG_CONFIG_HOME")) {
confpath = env_util::get("XDG_CONFIG_HOME") + "/polybar/config";
} else if (env_util::has("HOME")) {
confpath = env_util::get("HOME") + "/.config/polybar/config";
} else {
throw application_error("Define configuration using --config=PATH");
}

  1. -c/--config parameter
  2. $XDG_CONFIG_HOME/polybar/config, if the variable is set
  3. $HOME/polybar/config, if the variable is set
  4. Throw error

I would like to propose the following behavior instead:

  1. -c/--config parameter
  2. $XDG_CONFIG_HOME/polybar/config, if the file exists (variable still needs to be checked)
  3. $HOME/polybar/config, if the file exists (variable still needs to be checked)
  4. /etc/polybar/config, if the file exists (and the file is installed there by default)
  5. Throw error

So a logic change in the way the config file is handled: check if the file exists instead of if the variables to generate the location are set, and fallback to /etc/polybar/config, while also shipping the file there instead of ${CMAKE_INSTALL_DOCDIR}:

polybar/CMakeLists.txt

Lines 163 to 165 in fab8437

install(FILES config
DESTINATION ${CMAKE_INSTALL_DOCDIR}
COMPONENT config)

The reason is ask this is because that will make it easier to ship polybar working out of the box, so that polybar example will work without the user having to copy the file to their $HOME, and it will work for any user.

Please note that if you agree with this, a change in the README will be needed to reflect it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions