add log file path to config, initialize default value
This commit is contained in:
parent
46d0bc1670
commit
a2384822d8
22
src/config.c
22
src/config.c
@ -1,6 +1,6 @@
|
|||||||
#include "config.h"
|
|
||||||
#include "wm.h"
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@ -10,6 +10,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "config.h"
|
||||||
|
#include "wm.h"
|
||||||
|
|
||||||
void wm_cfg_init_def(Config *config)
|
void wm_cfg_init_def(Config *config)
|
||||||
{
|
{
|
||||||
@ -20,6 +24,20 @@ void wm_cfg_init_def(Config *config)
|
|||||||
config->focus_on_motion = true;
|
config->focus_on_motion = true;
|
||||||
|
|
||||||
wm_keybinds_init_def(config);
|
wm_keybinds_init_def(config);
|
||||||
|
|
||||||
|
char log_file_dir[PATH_MAX] = {0};
|
||||||
|
const char* log_file_name = "wm.json";
|
||||||
|
char *xdg_data_home = getenv("XDG_DATA_HOME");
|
||||||
|
|
||||||
|
if (!xdg_data_home) {
|
||||||
|
char *home = getenv("HOME");
|
||||||
|
assert(home);
|
||||||
|
snprintf(log_file_dir, sizeof(log_file_dir), "%s/.local/share", home);
|
||||||
|
} else {
|
||||||
|
strncpy(log_file_dir, xdg_data_home, PATH_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(config->log_path, PATH_MAX, "%s/%s", log_file_dir, log_file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wm_keybinds_init_def(Config *config)
|
void wm_keybinds_init_def(Config *config)
|
||||||
|
@ -78,6 +78,7 @@ typedef struct {
|
|||||||
Keybind *keybinds;
|
Keybind *keybinds;
|
||||||
int kb_count;
|
int kb_count;
|
||||||
bool focus_on_motion;
|
bool focus_on_motion;
|
||||||
|
char log_path[PATH_MAX];
|
||||||
} Config;
|
} Config;
|
||||||
|
|
||||||
void wm_cfg_init_def(Config *config);
|
void wm_cfg_init_def(Config *config);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user