aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/swaynag/swaynag.h2
-rw-r--r--swaynag/config.c4
-rw-r--r--swaynag/main.c20
3 files changed, 8 insertions, 18 deletions
diff --git a/include/swaynag/swaynag.h b/include/swaynag/swaynag.h
index baa6ee8b..2d68b6c9 100644
--- a/include/swaynag/swaynag.h
+++ b/include/swaynag/swaynag.h
@@ -67,7 +67,7 @@ struct swaynag_details {
int offset;
int visible_lines;
int total_lines;
- struct swaynag_button *button_details;
+ struct swaynag_button button_details;
struct swaynag_button button_up;
struct swaynag_button button_down;
};
diff --git a/swaynag/config.c b/swaynag/config.c
index 73fc41c8..b212a0c3 100644
--- a/swaynag/config.c
+++ b/swaynag/config.c
@@ -232,8 +232,8 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
break;
case 'L': // Detailed Button Text
if (swaynag) {
- free(swaynag->details.button_details->text);
- swaynag->details.button_details->text = strdup(optarg);
+ free(swaynag->details.button_details.text);
+ swaynag->details.button_details.text = strdup(optarg);
}
break;
case 'm': // Message
diff --git a/swaynag/main.c b/swaynag/main.c
index 0c94cb1a..112a8b2f 100644
--- a/swaynag/main.c
+++ b/swaynag/main.c
@@ -40,15 +40,6 @@ int main(int argc, char **argv) {
button_close->type = SWAYNAG_ACTION_DISMISS;
list_add(swaynag.buttons, button_close);
- swaynag.details.button_details =
- calloc(sizeof(struct swaynag_button), 1);
- if (!swaynag.details.button_details) {
- perror("calloc");
- return EXIT_FAILURE;
- }
- 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 = swaynag_parse_options(argc, argv, NULL, NULL, NULL,
@@ -72,6 +63,9 @@ int main(int argc, char **argv) {
}
}
+ swaynag.details.button_details.text = strdup("Toggle details");
+ swaynag.details.button_details.type = SWAYNAG_ACTION_EXPAND;
+
if (argc > 1) {
struct swaynag_type *type_args = swaynag_type_new("<args>");
list_add(types, type_args);
@@ -107,10 +101,7 @@ int main(int argc, char **argv) {
swaynag_types_free(types);
if (swaynag.details.message) {
- list_add(swaynag.buttons, swaynag.details.button_details);
- } else {
- free(swaynag.details.button_details->text);
- free(swaynag.details.button_details);
+ list_add(swaynag.buttons, &swaynag.details.button_details);
}
sway_log(SWAY_DEBUG, "Output: %s", swaynag.type->output);
@@ -132,8 +123,7 @@ int main(int argc, char **argv) {
cleanup:
swaynag_types_free(types);
- free(swaynag.details.button_details->text);
- free(swaynag.details.button_details);
+ free(swaynag.details.button_details.text);
swaynag_destroy(&swaynag);
return exit_code;
}