From a0afae747b60649ea23efc785255b6f2dece67d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 16 Jan 2021 11:26:03 +0100 Subject: [PATCH] =?UTF-8?q?config:=20add=20new=20option=20=E2=80=98selecti?= =?UTF-8?q?on-target=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This option controls the clipboard target that selected text should be copied to. --- config.c | 17 +++++++++++++++++ config.h | 5 +++++ foot.ini | 1 + 3 files changed, 23 insertions(+) diff --git a/config.c b/config.c index 54c8e60f..08a46a4a 100644 --- a/config.c +++ b/config.c @@ -602,6 +602,22 @@ parse_section_main(const char *key, const char *value, struct config *conf, conf->notify.argv = argv; } + else if (strcmp(key, "selection-target") == 0) { + if (strcasecmp(value, "primary") == 0) + conf->selection_target = SELECTION_TARGET_PRIMARY; + else if (strcasecmp(value, "clipboard") == 0) + conf->selection_target = SELECTION_TARGET_CLIPBOARD; + else if (strcasecmp(value, "both") == 0) + conf->selection_target = SELECTION_TARGET_BOTH; + else { + LOG_AND_NOTIFY_ERR( + "%s:%d: [default]: %s: invalid 'selection-target'; " + "must be one of 'primary', 'clipboard' or 'both", + path, lineno, value); + return false; + } + } + else { LOG_AND_NOTIFY_ERR("%s:%u: [default]: %s: invalid key", path, lineno, key); return false; @@ -2037,6 +2053,7 @@ config_load(struct config *conf, const char *conf_path, .render_worker_count = sysconf(_SC_NPROCESSORS_ONLN), .server_socket_path = get_server_socket_path(), .presentation_timings = false, + .selection_target = SELECTION_TARGET_PRIMARY, .hold_at_exit = false, .notify = { .raw_cmd = NULL, diff --git a/config.h b/config.h index a1b27c04..db9a5b39 100644 --- a/config.h +++ b/config.h @@ -166,6 +166,11 @@ struct config { char *server_socket_path; bool presentation_timings; bool hold_at_exit; + enum { + SELECTION_TARGET_PRIMARY, + SELECTION_TARGET_CLIPBOARD, + SELECTION_TARGET_BOTH + } selection_target; struct { char *raw_cmd; diff --git a/foot.ini b/foot.ini index baf0df84..0443b85f 100644 --- a/foot.ini +++ b/foot.ini @@ -17,6 +17,7 @@ # bell=none # word-delimiters=,│`|:"'()[]{}<> # notify=notify-send -a foot -i foot ${title} ${body} +# selection-target=primary [scrollback] # lines=1000