diff --git a/zathura/commands.c b/zathura/commands.c index 7c58656..16b2fe3 100644 --- a/zathura/commands.c +++ b/zathura/commands.c @@ -19,6 +19,7 @@ #include "internal.h" #include "render.h" #include "adjustment.h" +#include "config.h" #include #include @@ -605,3 +606,24 @@ cmd_version(girara_session_t* session, girara_list_t* UNUSED(argument_list)) return true; } + +bool +cmd_source(girara_session_t* session, girara_list_t* argument_list) +{ + g_return_val_if_fail(session != NULL, false); + g_return_val_if_fail(session->global.data != NULL, false); + zathura_t* zathura = session->global.data; + + const int argc = girara_list_size(argument_list); + if (argc > 1) { + girara_notify(session, GIRARA_ERROR, _("Too many arguments.")); + return false; + } else if (argc == 1) { + zathura_set_config_dir(zathura, girara_list_nth(argument_list, 0)); + config_load_files(zathura); + } else { + config_load_files(zathura); + } + + return true; +} diff --git a/zathura/commands.h b/zathura/commands.h index 9063f61..7965b71 100644 --- a/zathura/commands.h +++ b/zathura/commands.h @@ -169,4 +169,13 @@ bool cmd_offset(girara_session_t* session, girara_list_t* argument_list); */ bool cmd_version(girara_session_t* session, girara_list_t* argument_list); +/** + * Source config file + * + * @param session The used girara session + * @param argument_list List of passed arguments + * @return true if no error occurred + */ +bool cmd_source(girara_session_t* session, girara_list_t* argument_list); + #endif // COMMANDS_H diff --git a/zathura/config.c b/zathura/config.c index 8f76a71..98f17c2 100644 --- a/zathura/config.c +++ b/zathura/config.c @@ -510,6 +510,7 @@ config_load_default(zathura_t* zathura) girara_inputbar_command_add(gsession, "nohlsearch", "nohl", cmd_nohlsearch, NULL, _("Don't highlight current search results")); girara_inputbar_command_add(gsession, "hlsearch", NULL, cmd_hlsearch, NULL, _("Highlight current search results")); girara_inputbar_command_add(gsession, "version", NULL, cmd_version, NULL, _("Show version information")); + girara_inputbar_command_add(gsession, "source", NULL, cmd_source, NULL, _("Source config file")); girara_special_command_add(gsession, '/', cmd_search, INCREMENTAL_SEARCH, FORWARD, NULL); girara_special_command_add(gsession, '?', cmd_search, INCREMENTAL_SEARCH, BACKWARD, NULL);