From 2ab4955c4671e7e1aa85bb28da37177d64134615 Mon Sep 17 00:00:00 2001 From: project-repo Date: Sun, 17 Oct 2021 07:50:03 +0200 Subject: [PATCH] Add support for default configuration file --- cagebreak.c | 14 ++++++++++++-- examples/config | 12 ++++++------ meson.build | 2 ++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/cagebreak.c b/cagebreak.c index 0738b67..838078f 100644 --- a/cagebreak.c +++ b/cagebreak.c @@ -192,7 +192,7 @@ set_configuration(struct cg_server *server, if(config_file == NULL) { wlr_log(WLR_ERROR, "Could not open config file \"%s\"", config_file_path); - return -1; + return 1; } char line[MAX_LINE_SIZE * sizeof(char)]; for(unsigned int line_num = 1; @@ -557,7 +557,17 @@ main(int argc, char *argv[]) { ret = 1; goto end; } - if(set_configuration(&server, config_file) != 0) { + int conf_ret = set_configuration(&server, config_file); + + // Configurtion file not found + if(conf_ret == 1) { + char *default_conf = "/etc/xdg/cagebreak/config"; + wlr_log(WLR_ERROR, "Loading default configuration file: \"%s\"", + default_conf); + conf_ret = set_configuration(&server, default_conf); + } + + if(conf_ret != 0) { free(config_file); ret = 1; goto end; diff --git a/examples/config b/examples/config index 0ecf20b..f701684 100644 --- a/examples/config +++ b/examples/config @@ -75,14 +75,14 @@ definekey top XF86MonBrightnessUp exec xbacklight -inc 1 ###################### #Output configuration ###################### -output eDP-1 pos 0 0 res 1366x768 rate 60 -output eDP-1 disable -output eDP-1 enable +#output eDP-1 pos 0 0 res 1366x768 rate 60 +#output eDP-1 disable +#output eDP-1 enable ##################### #Input configuration ##################### -input 1234:0:Device_Ident click_method clickfinger -input type:pointer scroll_method two_finger -input * calibration_matrix 1 2 3 4 5 6 +#input 1234:0:Device_Ident click_method clickfinger +#input type:pointer scroll_method two_finger +#input * calibration_matrix 1 2 3 4 5 6 diff --git a/meson.build b/meson.build index e8a2cfd..5b7a377 100644 --- a/meson.build +++ b/meson.build @@ -258,6 +258,8 @@ executable( c_args: fuzz_compile_args, ) +install_data('examples/config',install_dir: '/etc/xdg/cagebreak') + if get_option('man-pages') scdoc = find_program('scdoc') sh = find_program('sh')