move configuration file to a directory

This commit is contained in:
Daniel Micay 2013-01-06 19:11:19 -05:00
parent bbf8a522bf
commit 16426ed18f
3 changed files with 17 additions and 10 deletions

View File

@ -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 File

View File

@ -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);
}/*}}}*/