diff options
Diffstat (limited to 'swaynag/main.c')
-rw-r--r-- | swaynag/main.c | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/swaynag/main.c b/swaynag/main.c index 5c97e12a..0493c1f0 100644 --- a/swaynag/main.c +++ b/swaynag/main.c @@ -3,19 +3,19 @@ #include "log.h" #include "list.h" #include "swaynag/config.h" -#include "swaynag/nagbar.h" +#include "swaynag/swaynag.h" #include "swaynag/types.h" #include "wlr-layer-shell-unstable-v1-client-protocol.h" -static struct sway_nagbar nagbar; +static struct swaynag swaynag; void sig_handler(int signal) { - nagbar_destroy(&nagbar); + swaynag_destroy(&swaynag); exit(EXIT_FAILURE); } void sway_terminate(int code) { - nagbar_destroy(&nagbar); + swaynag_destroy(&swaynag); exit(code); } @@ -23,28 +23,28 @@ int main(int argc, char **argv) { int exit_code = EXIT_SUCCESS; list_t *types = create_list(); - nagbar_types_add_default(types); + swaynag_types_add_default(types); - memset(&nagbar, 0, sizeof(nagbar)); - nagbar.anchors = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP + memset(&swaynag, 0, sizeof(swaynag)); + swaynag.anchors = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT; - nagbar.font = strdup("pango:monospace 10"); - nagbar.buttons = create_list(); + swaynag.font = strdup("pango:monospace 10"); + swaynag.buttons = create_list(); - struct sway_nagbar_button *button_close = - calloc(sizeof(struct sway_nagbar_button), 1); + struct swaynag_button *button_close = + calloc(sizeof(struct swaynag_button), 1); button_close->text = strdup("X"); - button_close->type = NAGBAR_ACTION_DISMISS; - list_add(nagbar.buttons, button_close); + button_close->type = SWAYNAG_ACTION_DISMISS; + list_add(swaynag.buttons, button_close); - nagbar.details.button_details.text = strdup("Toggle Details"); - nagbar.details.button_details.type = NAGBAR_ACTION_EXPAND; + swaynag.details.button_details.text = strdup("Toggle Details"); + swaynag.details.button_details.type = SWAYNAG_ACTION_EXPAND; char *config_path = NULL; bool debug = false; - int launch_status = nagbar_parse_options(argc, argv, NULL, NULL, + int launch_status = swaynag_parse_options(argc, argv, NULL, NULL, &config_path, &debug); if (launch_status != 0) { exit_code = launch_status; @@ -53,11 +53,11 @@ int main(int argc, char **argv) { wlr_log_init(debug ? WLR_DEBUG : WLR_ERROR, NULL); if (!config_path) { - config_path = nagbar_get_config_path(); + config_path = swaynag_get_config_path(); } if (config_path) { wlr_log(WLR_DEBUG, "Loading config file: %s", config_path); - int config_status = nagbar_load_config(config_path, &nagbar, types); + int config_status = swaynag_load_config(config_path, &swaynag, types); free(config_path); if (config_status != 0) { exit_code = config_status; @@ -66,7 +66,7 @@ int main(int argc, char **argv) { } if (argc > 1) { - int result = nagbar_parse_options(argc, argv, &nagbar, types, + int result = swaynag_parse_options(argc, argv, &swaynag, types, NULL, NULL); if (result != 0) { exit_code = result; @@ -74,46 +74,46 @@ int main(int argc, char **argv) { } } - if (!nagbar.message) { + if (!swaynag.message) { wlr_log(WLR_ERROR, "No message passed. Please provide --message/-m"); exit_code = EXIT_FAILURE; goto cleanup; } - if (!nagbar.type) { - nagbar.type = nagbar_type_get(types, "error"); + if (!swaynag.type) { + swaynag.type = swaynag_type_get(types, "error"); } - nagbar.type = nagbar_type_clone(nagbar.type); - nagbar_types_free(types); + swaynag.type = swaynag_type_clone(swaynag.type); + swaynag_types_free(types); - if (nagbar.details.message) { - list_add(nagbar.buttons, &nagbar.details.button_details); + if (swaynag.details.message) { + list_add(swaynag.buttons, &swaynag.details.button_details); } else { - free(nagbar.details.button_details.text); + free(swaynag.details.button_details.text); } - wlr_log(WLR_DEBUG, "Output: %s", nagbar.output.name); - wlr_log(WLR_DEBUG, "Anchors: %d", nagbar.anchors); - wlr_log(WLR_DEBUG, "Type: %s", nagbar.type->name); - wlr_log(WLR_DEBUG, "Message: %s", nagbar.message); - wlr_log(WLR_DEBUG, "Font: %s", nagbar.font); + wlr_log(WLR_DEBUG, "Output: %s", swaynag.output.name); + wlr_log(WLR_DEBUG, "Anchors: %d", swaynag.anchors); + wlr_log(WLR_DEBUG, "Type: %s", swaynag.type->name); + wlr_log(WLR_DEBUG, "Message: %s", swaynag.message); + wlr_log(WLR_DEBUG, "Font: %s", swaynag.font); wlr_log(WLR_DEBUG, "Buttons"); - for (int i = 0; i < nagbar.buttons->length; i++) { - struct sway_nagbar_button *button = nagbar.buttons->items[i]; + for (int i = 0; i < swaynag.buttons->length; i++) { + struct swaynag_button *button = swaynag.buttons->items[i]; wlr_log(WLR_DEBUG, "\t[%s] `%s`", button->text, button->action); } signal(SIGTERM, sig_handler); - nagbar_setup(&nagbar); - nagbar_run(&nagbar); + swaynag_setup(&swaynag); + swaynag_run(&swaynag); return exit_code; cleanup: - nagbar_types_free(types); - free(nagbar.details.button_details.text); - nagbar_destroy(&nagbar); + swaynag_types_free(types); + free(swaynag.details.button_details.text); + swaynag_destroy(&swaynag); return exit_code; } |