wayclip

Wayland clipboard utility
git clone git://git.nihaljere.xyz/wayclip
Log | Files | Refs | README | LICENSE

commit 594776c248622e1570e9d5e94b6aa5126e5042c7
parent cae71f300241f621cdbf737000ba12fa5cee50a4
Author: Nihal Jere <nihal@nihaljere.xyz>
Date:   Tue,  4 Oct 2022 20:21:31 -0500

add primary clipboard support with -p

This requires wlr-data-control v2, so bump the version accordingly.

Diffstat:
Mcommon.c | 5++++-
Mcommon.h | 1+
Mwaycopy.c | 8++++++--
3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/common.c b/common.c @@ -48,7 +48,7 @@ registry_global(void *data, struct wl_registry *registry, uint32_t name, const c seat = NULL; } else seat_found = true; } else if (strcmp(interface, "zwlr_data_control_manager_v1") == 0) { - data_control_manager = wl_registry_bind(registry, name, &zwlr_data_control_manager_v1_interface, 1); + data_control_manager = wl_registry_bind(registry, name, &zwlr_data_control_manager_v1_interface, 2); } } @@ -132,6 +132,9 @@ parseopts(const char *opts, int argc, char *const argv[]) break; case 'h': usage(0); + case 'p': + options.primary = true; + break; case 's': options.seat = optarg; break; diff --git a/common.h b/common.h @@ -8,6 +8,7 @@ extern struct options { const char *type; const char *seat; bool foreground; + bool primary; } options; void die(const char *const error); diff --git a/waycopy.c b/waycopy.c @@ -42,7 +42,7 @@ int main(int argc, char *argv[]) { argv0 = argv[0]; - parseopts("hfs:t:", argc, argv); + parseopts("hfps:t:", argc, argv); char path[PATH_MAX] = {0}; char *ptr = getenv("TMPDIR"); @@ -95,7 +95,11 @@ main(int argc, char *argv[]) zwlr_data_control_source_v1_offer(source, options.type); zwlr_data_control_source_v1_add_listener(source, &data_source_listener, NULL); - zwlr_data_control_device_v1_set_selection(device, source); + + if (options.primary) + zwlr_data_control_device_v1_set_primary_selection(device, source); + else + zwlr_data_control_device_v1_set_selection(device, source); if (!options.foreground) { pid_t pid = fork();