aboutsummaryrefslogtreecommitdiff
path: root/swaynag/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaynag/main.c')
-rw-r--r--swaynag/main.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/swaynag/main.c b/swaynag/main.c
index 0493c1f0..20d03c31 100644
--- a/swaynag/main.c
+++ b/swaynag/main.c
@@ -5,7 +5,6 @@
#include "swaynag/config.h"
#include "swaynag/swaynag.h"
#include "swaynag/types.h"
-#include "wlr-layer-shell-unstable-v1-client-protocol.h"
static struct swaynag swaynag;
@@ -26,10 +25,6 @@ int main(int argc, char **argv) {
swaynag_types_add_default(types);
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;
- swaynag.font = strdup("pango:monospace 10");
swaynag.buttons = create_list();
struct swaynag_button *button_close =
@@ -44,7 +39,7 @@ int main(int argc, char **argv) {
char *config_path = NULL;
bool debug = false;
- int launch_status = swaynag_parse_options(argc, argv, NULL, NULL,
+ int launch_status = swaynag_parse_options(argc, argv, NULL, NULL, NULL,
&config_path, &debug);
if (launch_status != 0) {
exit_code = launch_status;
@@ -66,8 +61,13 @@ int main(int argc, char **argv) {
}
if (argc > 1) {
+ struct swaynag_type *type_args;
+ type_args = calloc(1, sizeof(struct swaynag_type));
+ type_args->name = strdup("<args>");
+ list_add(types, type_args);
+
int result = swaynag_parse_options(argc, argv, &swaynag, types,
- NULL, NULL);
+ type_args, NULL, NULL);
if (result != 0) {
exit_code = result;
goto cleanup;
@@ -84,7 +84,20 @@ int main(int argc, char **argv) {
swaynag.type = swaynag_type_get(types, "error");
}
- swaynag.type = swaynag_type_clone(swaynag.type);
+ // Construct a new type using the config defaults as base, then merging
+ // config type defaults on top, then merging arguments on top of that, and
+ // finally merging defaults on top.
+ struct swaynag_type *type = calloc(1, sizeof(struct swaynag_type));
+ type->name = strdup(swaynag.type->name);
+ swaynag_type_merge(type, swaynag_type_get(types, "<args>"));
+ swaynag_type_merge(type, swaynag.type);
+ swaynag_type_merge(type, swaynag_type_get(types, "<config>"));
+ swaynag_type_merge(type, swaynag_type_get(types, "<defaults>"));
+ swaynag.type = type;
+ if (swaynag.type->output) {
+ swaynag.output.name = strdup(swaynag.type->output);
+ }
+
swaynag_types_free(types);
if (swaynag.details.message) {
@@ -94,10 +107,10 @@ int main(int argc, char **argv) {
}
wlr_log(WLR_DEBUG, "Output: %s", swaynag.output.name);
- wlr_log(WLR_DEBUG, "Anchors: %d", swaynag.anchors);
+ wlr_log(WLR_DEBUG, "Anchors: %d", swaynag.type->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, "Font: %s", swaynag.type->font);
wlr_log(WLR_DEBUG, "Buttons");
for (int i = 0; i < swaynag.buttons->length; i++) {
struct swaynag_button *button = swaynag.buttons->items[i];