From 56860d672fccab805740443ca63b58bfe46f8675 Mon Sep 17 00:00:00 2001 From: Alexey Yerin Date: Sun, 30 Jun 2024 17:47:31 +0300 Subject: [PATCH] Add option to disable persistence --- dulcepan.cfg | 3 +++ src/config.c | 3 +++ src/dulcepan.h | 1 + src/main.c | 8 ++++++-- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dulcepan.cfg b/dulcepan.cfg index e4408ec..2cacb6f 100644 --- a/dulcepan.cfg +++ b/dulcepan.cfg @@ -33,6 +33,9 @@ animation-duration = 0 # or when a whole output is selected with a mouse button. quick-select = false +# If true, dulcepan will remember selection between runs +persistence = true + # PNG (zlib) compression level, 0-9 png-compression = 6 diff --git a/src/config.c b/src/config.c index 0b35fe5..3176037 100644 --- a/src/config.c +++ b/src/config.c @@ -98,6 +98,7 @@ void dp_config_load(struct dp_state *state, const char *user_path) { .animation_duration = 0, .png_compression = 6, .quick_select = false, + .persistence = true, }; bytes_to_color((uint8_t[]){0xff, 0xff, 0xff, 0x40}, config->unselected_color); bytes_to_color((uint8_t[]){0x00, 0x00, 0x00, 0x00}, config->selected_color); @@ -211,6 +212,8 @@ void dp_config_load(struct dp_state *state, const char *user_path) { load_int(value, line_idx, 0, 9, &config->png_compression); } else if (strcmp(key, "quick-select") == 0) { load_bool(value, line_idx, &config->quick_select); + } else if (strcmp(key, "persistence") == 0) { + load_bool(value, line_idx, &config->persistence); } else if (strcmp(key, "quit-key") == 0) { load_key(value, line_idx, &config->quit_key); } else if (strcmp(key, "save-key") == 0) { diff --git a/src/dulcepan.h b/src/dulcepan.h index ce69412..46941e5 100644 --- a/src/dulcepan.h +++ b/src/dulcepan.h @@ -156,6 +156,7 @@ struct dp_config { int png_compression; bool quick_select; + bool persistence; }; struct dp_state { diff --git a/src/main.c b/src/main.c index 6d16bc2..d632592 100644 --- a/src/main.c +++ b/src/main.c @@ -108,7 +108,9 @@ static void run(struct dp_state *state) { } } - dp_persistent_load(state); + if (state->config.persistence) { + dp_persistent_load(state); + } wl_list_for_each (output, &state->outputs, link) { dp_output_redraw(output); @@ -128,7 +130,9 @@ static void run(struct dp_state *state) { dp_save(state); } - dp_persistent_save(state); + if (state->config.persistence) { + dp_persistent_save(state); + } struct dp_seat *seat, *seat_tmp; wl_list_for_each_safe (seat, seat_tmp, &state->seats, link) {