xsel

Program for manipulating the X clipboard
git clone https://git.sinitax.com/kfish/xsel
Log | Files | Refs | README | LICENSE | sfeed.txt

commit 9fc4e3e4e3f1231cabfdc2e1438155f9390bc517
parent b2715dea1b98e6c1b2a5cc51d122a63cc5748b1e
Author: Conrad Parker <conrad@metadecks.org>
Date:   Thu, 10 Mar 2022 14:52:47 +0800

Merge pull request #35 from uosis/master

Set WM_NAME and WM_CLASS window properties
Diffstat:
Mxsel.1x | 3+++
Mxsel.c | 19++++++++++++++++++-
2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/xsel.1x b/xsel.1x @@ -85,6 +85,9 @@ and \fIoutput\fR options. \fB\-\-display\fR \fIdisplayname\fR specify the server to use; see \fIX(1)\fP. .TP +\fB\-\-windowName\fR \fIwindowName\fR +specify the X WM_NAME window property; default is "xsel". +.TP \fB\-t\fR \fIms\fR, \fB\-\-selectionTimeout\fR \fIms\fR Specify the timeout in milliseconds within which the selection must be retrieved. In \fB\-\-input\fR mode, the background process exits after this diff --git a/xsel.c b/xsel.c @@ -31,6 +31,7 @@ #include <signal.h> #include <X11/Xlib.h> #include <X11/Xatom.h> +#include <X11/Xutil.h> #include "xsel.h" @@ -2034,11 +2035,12 @@ main(int argc, char *argv[]) Bool trim_trailing_newline = False; Window root; Atom selection = XA_PRIMARY, test_atom; + XClassHint * class_hints; int black; int i, s=0; unsigned char * old_sel = NULL, * new_sel = NULL; char * display_name = NULL; - char * window_name = NULL; + char * window_name = "xsel"; long timeout_ms = 0L; zerot.it_value.tv_sec = 0; @@ -2118,6 +2120,9 @@ main(int argc, char *argv[]) } else if (OPT("--display")) { i++; if (i >= argc) goto usage_err; display_name = argv[i]; + } else if (OPT("--windowName")) { + i++; if (i >= argc) goto usage_err; + window_name = argv[i]; } else if (OPT("--selectionTimeout") || OPT("-t")) { i++; if (i >= argc) goto usage_err; timeout_ms = strtol(argv[i], (char **)NULL, 10); @@ -2188,6 +2193,18 @@ main(int argc, char *argv[]) print_debug (D_INFO, "The name %s is assigned to the window", window_name); } + /* Set window name and class */ + XStoreName(display, window, window_name); + + class_hints = XAllocClassHint(); + if (class_hints==NULL) { + exit_err ("Can't allocate class hints memory\n"); + } + class_hints->res_name = "xsel"; + class_hints->res_class = "XSel"; + XSetClassHint(display, window, class_hints); + XFree(class_hints); + /* Get a timestamp */ XSelectInput (display, window, PropertyChangeMask); timestamp = get_timestamp ();