Skip to content
Browse files

move configuration file to a directory

  • Loading branch information...
1 parent bbf8a52 commit 16426ed18f7aab0061c5e442937e2266dd4a12ad @thestinger committed Jan 6, 2013
Showing with 17 additions and 10 deletions.
  1. +3 −2 README.rst
  2. 0 termite.cfg → config
  3. +14 −8 termite.cc
View
5 README.rst
@@ -1,8 +1,9 @@
A keyboard-centric VTE-based terminal, aimed at use within a window manager
with tiling and/or tabbing support.
-Termite looks for ``termite.cfg`` in ``$XDG_CONFIG_HOME`` (``~/.config`` if
-unset) and then falls back to ``$XDG_CONFIG_DIRS`` (``/etc/xdg`` if unset).
+Termite looks for the configuration file in the following order:
+``$XDG_CONFIG_HOME/termite/config``, ``~/.config/termite/config``,
+``$XDG_CONFIG_DIRS/termite/config``, ``/etc/xdg/termite.cfg``.
Termite's exit status is 1 on a failure, including a termination of the child
process from an uncaught signal. Otherwise the exit status is that of the child
View
0 termite.cfg → config
File renamed without changes.
View
22 termite.cc
@@ -7,6 +7,7 @@
#include <memory>
#include <vector>
#include <set>
+#include <string>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
@@ -1031,15 +1032,21 @@ static void load_theme(VteTerminal *vte, GKeyFile *config, hint_info &hints) {
static void load_config(GtkWindow *window, VteTerminal *vte, config_info *info,
char **geometry) {
-
- const char *const filename = "termite.cfg";
- char *path = g_build_filename(g_get_user_config_dir(), filename, nullptr);
+ const std::string path = "/termite/config";
GKeyFile *config = g_key_file_new();
- if ((g_key_file_load_from_file(config, path, G_KEY_FILE_NONE, NULL) ||
- g_key_file_load_from_dirs(config, filename,
- const_cast<const char **>(g_get_system_config_dirs()),
- NULL, G_KEY_FILE_NONE, NULL))) {
+ gboolean loaded;
+ loaded = g_key_file_load_from_file(config,
+ (g_get_user_config_dir() + path).c_str(),
+ G_KEY_FILE_NONE, nullptr);
+
+ for (const char *const *dir = g_get_system_config_dirs();
+ !loaded && *dir; dir++) {
+ loaded = g_key_file_load_from_file(config, (*dir + path).c_str(),
+ G_KEY_FILE_NONE, nullptr);
+ }
+
+ if (loaded) {
if (geometry) {
if (auto s = get_config_string(config, "options", "geometry")) {
*geometry = *s;
@@ -1150,7 +1157,6 @@ static void load_config(GtkWindow *window, VteTerminal *vte, config_info *info,
load_theme(vte, config, info->hints);
}
- g_free(path);
g_key_file_free(config);
}/*}}}*/

0 comments on commit 16426ed

Please sign in to comment.
Something went wrong with that request. Please try again.