diff --git a/cmake/ConkyBuildOptions.cmake b/cmake/ConkyBuildOptions.cmake index 1a6e3404..6f2c0ff8 100644 --- a/cmake/ConkyBuildOptions.cmake +++ b/cmake/ConkyBuildOptions.cmake @@ -49,11 +49,11 @@ mark_as_advanced(RELEASE) option(MAINTAINER_MODE "Enable maintainer mode (builds docs)" false) # Some standard options -set(SYSTEM_CONFIG_FILE "/etc/conky/conky.conf" CACHE STRING "Default system-wide Conky configuration file") +set(SYSTEM_CONFIG_FILE "/etc/conky/conky2.conf" CACHE STRING "Default system-wide Conky configuration file") # use FORCE below to make sure this changes when CMAKE_INSTALL_PREFIX is modified set(PACKAGE_LIBRARY_DIR "${CMAKE_INSTALL_PREFIX}/lib/conky" CACHE STRING "Package library path (where Lua bindings are installed" FORCE) set(DEFAULTNETDEV "eth0" CACHE STRING "Default networkdevice") -set(CONFIG_FILE "$HOME/.conkyrc" CACHE STRING "Configfile of the user") +set(CONFIG_FILE "$HOME/.conky2rc" CACHE STRING "Configfile of the user") set(MAX_USER_TEXT_DEFAULT "16384" CACHE STRING "Default maximum size of config TEXT buffer, i.e. below TEXT line.") set(DEFAULT_TEXT_BUFFER_SIZE "256" CACHE STRING "Default size used for temporary, static text buffers") set(MAX_NET_INTERFACES "16" CACHE STRING "Maximum number of network devices") diff --git a/src/conky.cc b/src/conky.cc index d11db153..327079e5 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -2942,36 +2942,33 @@ static const struct option longopts[] = { void set_current_config() { /* load current_config, CONFIG_FILE or SYSTEM_CONFIG_FILE */ + struct stat s; if (current_config.empty()) { - /* load default config file */ - FILE *fp; - /* Try to use personal config file first */ std::string buf = to_real_path(CONFIG_FILE); - if (!buf.empty() && (fp = fopen(buf.c_str(), "r"))) { + if (stat(buf.c_str(), &s) == 0) current_config = buf; - fclose(fp); - } - - /* Try to use system config file if personal config not readable */ - if (current_config.empty() && (fp = fopen(SYSTEM_CONFIG_FILE, "r"))) { - current_config = SYSTEM_CONFIG_FILE; - fclose(fp); - } - - /* No readable config found */ - if (current_config.empty()) { -#define NOCFGFILEFOUND "no readable personal or system-wide config file found" -#ifdef BUILD_BUILTIN_CONFIG - current_config = "==builtin=="; - NORM_ERR(NOCFGFILEFOUND - ", using builtin default"); -#else - CRIT_ERR(NULL, NULL, NOCFGFILEFOUND); -#endif /* ! CONF_OUTPUT */ - } } + + /* Try to use system config file if personal config does not exist */ + if (current_config.empty() && (stat(SYSTEM_CONFIG_FILE, &s)==0)) + current_config = SYSTEM_CONFIG_FILE; + + /* No readable config found */ + if (current_config.empty()) { +#define NOCFGFILEFOUND "no personal or system-wide config file found" +#ifdef BUILD_BUILTIN_CONFIG + current_config = "==builtin=="; + NORM_ERR(NOCFGFILEFOUND ", using builtin default"); +#else + CRIT_ERR(NULL, NULL, NOCFGFILEFOUND); +#endif + } + + // "-" stands for "read from stdin" + if(current_config == "-") + current_config = "/dev/stdin"; } void initialisation(int argc, char **argv) {