1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 20:31:17 +00:00

Config file handling changes

- changed default config filenames, to avoid conflict with conky-1.x
- specifying "-" as config file reads from stdin
- if a user config file exists but is not readable, report an error instead of falling back to
  the system-wide config.
This commit is contained in:
Pavel Labath 2010-09-12 14:01:34 +02:00
parent 4426a8fa5b
commit 55282b64d8
2 changed files with 23 additions and 26 deletions

View File

@ -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")

View File

@ -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"))) {
/* 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;
fclose(fp);
}
/* No readable config found */
if (current_config.empty()) {
#define NOCFGFILEFOUND "no readable personal or system-wide config file found"
#define NOCFGFILEFOUND "no personal or system-wide config file found"
#ifdef BUILD_BUILTIN_CONFIG
current_config = "==builtin==";
NORM_ERR(NOCFGFILEFOUND
", using builtin default");
NORM_ERR(NOCFGFILEFOUND ", using builtin default");
#else
CRIT_ERR(NULL, NULL, NOCFGFILEFOUND);
#endif /* ! CONF_OUTPUT */
}
#endif
}
// "-" stands for "read from stdin"
if(current_config == "-")
current_config = "/dev/stdin";
}
void initialisation(int argc, char **argv) {