Skip to content

Commit

Permalink
Read configuration from ~/.config/conky/conky.conf
Browse files Browse the repository at this point in the history
Try to load configuration from ~/.config/conky/conky.conf before
falling back to ~/.conkyrc and /etc/conky/conky.conf.
  • Loading branch information
steelman committed Nov 17, 2014
1 parent b03d88d commit 00481ee
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 11 deletions.
1 change: 1 addition & 0 deletions cmake/ConkyBuildOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ set(SYSTEM_CONFIG_FILE "/etc/conky/conky.conf" CACHE STRING "Default system-wide
# 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(XDG_CONFIG_FILE "$HOME/.config/conky/conky.conf" CACHE STRING "Configfile of the user (XDG)")
set(CONFIG_FILE "$HOME/.conkyrc" 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")
Expand Down
1 change: 1 addition & 0 deletions cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define SYSTEM_CONFIG_FILE "@SYSTEM_CONFIG_FILE@"
#define PACKAGE_LIBDIR "@PACKAGE_LIBRARY_DIR@"
#define DEFAULTNETDEV "@DEFAULTNETDEV@"
#define XDG_CONFIG_FILE "@XDG_CONFIG_FILE@"
#define CONFIG_FILE "@CONFIG_FILE@"
#define LOCALE_DIR "@LOCALE_DIR@"
#define MAX_USER_TEXT_DEFAULT @MAX_USER_TEXT_DEFAULT@
Expand Down
2 changes: 1 addition & 1 deletion doc/command_options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</command>
<option>FILE</option>
</term>
<listitem>Config file to load instead of $HOME/.conkyrc
<listitem>Config file to load instead of $HOME/.config/conky/conky.conf
<para></para></listitem>
</varlistentry>
<varlistentry>
Expand Down
2 changes: 1 addition & 1 deletion doc/config_settings.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<xsl:template match="/">
<html>
<head>
<title>~/.conkyrc settings</title>
<title>~/.config/conky/conky.conf settings</title>
</head>
<body bgcolor="#FFFFFF">
<xsl:apply-templates />
Expand Down
5 changes: 3 additions & 2 deletions doc/conky-howto.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ Once you have an idea of how Conky looks, you can now move on to configuring it!
<body>

<p>
By default, Conky will look for a configuration file in the users home directory located at <path>~/.conkyrc</path> This file contains all the configuration options, and the static text, colors and other variables which control what data is shown to the user. Conky also provides a great sample configuration, located at <path>/usr/share/doc/conky-version/Conkyrc.sample.gz</path> Make sure to replace "version" with the specific version of Conky you have installed.
By default, Conky will look for a configuration file in the users home directory located at <path>~/.config/conky/conky.conf</path> This file contains all the configuration options, and the static text, colors and other variables which control what data is shown to the user. Conky also provides a great sample configuration, located at <path>/usr/share/doc/conky-version/Conkyrc.sample.gz</path> Make sure to replace "version" with the specific version of Conky you have installed.
</p>

<pre caption="Copying the sample configuration to your home directory">
$ <i>zcat /usr/share/conky-1.6.0/conkyrc.sample.gz >> ~/.conkyrc</i>
$ <i>mkdir -p ~/.config/conky</i>
$ <i>zcat /usr/share/conky-1.6.0/conkyrc.sample.gz >> ~/.config/conky/conky.conf</i>
</pre>

<note>
Expand Down
14 changes: 7 additions & 7 deletions doc/docs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
the more you try to make Conky do, the more resources it is
going to consume.
</para>
<para>An easy way to force Conky to reload your ~/.conkyrc:
<para>An easy way to force Conky to reload your ~/.config/conky/conky.conf:
"killall -SIGUSR1 conky". Saves you the trouble of having
to kill and then restart. You can now also do the same with
SIGHUP.
Expand All @@ -159,12 +159,12 @@
</refsect1>
<refsect1>
<title>Configuration Settings</title>
<para>Default configuration file location is $HOME/.conkyrc or
<para>Default configuration file location is $HOME/.config/conky/conky.conf or
${sysconfdir}/conky/conky.conf. On most systems, sysconfdir is
/etc, and you can find the sample config file there
(/etc/conky/conky.conf).
</para>
<para>You might want to copy it to $HOME/.conkyrc and then
<para>You might want to copy it to $HOME/.config/conky/conky.conf and then
start modifying it. Other configs can be found at
http://conky.sf.net/
</para>
Expand Down Expand Up @@ -241,11 +241,11 @@
<varlistentry>
<term>
<varname>conky</varname>
<option>-C &gt; ~/.conkyrc</option>
<option>-C &gt; ~/.config/conky/conky.conf</option>
</term>
<listitem>Do not start Conky, but have it output
the builtin default config file to ~/.conkyrc for
later customising.</listitem>
the builtin default config file to
~/.config/conky/conky.conf for later customising.</listitem>
</varlistentry>
</variablelist>
</refsect1>
Expand All @@ -263,7 +263,7 @@
</varlistentry>
<varlistentry>
<term>
<filename>~/.conkyrc</filename>
<filename>~/.config/conky/rc</filename>
</term>
<listitem>Default personal configuration
file.</listitem>
Expand Down
7 changes: 7 additions & 0 deletions src/conky.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2826,6 +2826,13 @@ void set_current_config() {
/* load current_config, CONFIG_FILE or SYSTEM_CONFIG_FILE */
struct stat s;

if (current_config.empty()) {
/* Try to use personal config file first */
std::string buf = to_real_path(XDG_CONFIG_FILE);
if (stat(buf.c_str(), &s) == 0)
current_config = buf;
}

if (current_config.empty()) {
/* Try to use personal config file first */
std::string buf = to_real_path(CONFIG_FILE);
Expand Down

0 comments on commit 00481ee

Please sign in to comment.