x11/xseticon: new port had been added (+)

Some X11 programs do not set their window icons which window
managers typically use to represent that program window in
switcher lists, taskbars, and so on; this little program can
be handy in this case.

The patch to enable window selection based on WM_CLASS hints
is courtesy of Victor Kareh.

WWW: http://www.leonerd.org.uk/code/xseticon/
This commit is contained in:
Alexey Dokuchaev 2024-12-13 19:38:34 +00:00
parent f961819591
commit 248938f607
5 changed files with 93 additions and 0 deletions

View file

@ -640,6 +640,7 @@
SUBDIR += xscreensaver.app
SUBDIR += xsel-conrad
SUBDIR += xset
SUBDIR += xseticon
SUBDIR += xsetroot
SUBDIR += xsettingsd
SUBDIR += xskyroot

27
x11/xseticon/Makefile Normal file
View file

@ -0,0 +1,27 @@
PORTNAME= xseticon
PORTVERSION= 0.1
DISTVERSIONSUFFIX= +bzr14
CATEGORIES= x11
MASTER_SITES= ${WWW}
MAINTAINER= danfe@FreeBSD.org
COMMENT= Set window icon for any given X11 window
WWW= http://www.leonerd.org.uk/code/xseticon/
LICENSE= GPLv2+
LIB_DEPENDS= libgd.so:graphics/gd
USES= gmake gnome pkgconfig xorg
USE_GNOME= glib20
USE_XORG= x11 xmu
PLIST_FILES= bin/${PORTNAME}
post-patch:
@${REINPLACE_CMD} -e 's,gcc,$${CC} $${CFLAGS},' ${WRKSRC}/Makefile
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${STAGEDIR}${PREFIX}/bin
.include <bsd.port.mk>

3
x11/xseticon/distinfo Normal file
View file

@ -0,0 +1,3 @@
TIMESTAMP = 1516047601
SHA256 (xseticon-0.1+bzr14.tar.gz) = 048a8339b47030ebbff9cce4b58cb071a5c5f5a2cd7ff1ecc8434f95b2f8e4c5
SIZE (xseticon-0.1+bzr14.tar.gz) = 10192

View file

@ -0,0 +1,58 @@
--- xseticon.c.orig 2018-01-15 20:20:01 UTC
+++ xseticon.c
@@ -46,6 +46,7 @@ void usage(int exitcode)
printf("options:\n");
printf(" -name <text> : apply icon to the window of the name supplied\n");
printf(" -id <windowid> : apply icon to the window id supplied\n");
+ printf(" -class <text> : apply icon to the window matching the class supplied\n");
printf("\n");
printf("Sets the window icon to the specified .png image. The image is loaded from\n");
printf("the file at runtime and sent to the X server; thereafter the file does not\n");
@@ -98,6 +99,30 @@ Window Window_With_Name(Display* dpy, Window top, char
return(w);
}
+Window Window_With_Class(Display* dpy, Window top, char* class)
+{
+ Window *children, dummy;
+ unsigned int nchildren;
+ int i;
+ Window w = 0;
+ XClassHint *hint = XAllocClassHint();
+
+ if (XGetClassHint(dpy, top, hint)
+ && (!strcmp(hint->res_class, class) || !strcmp(hint->res_name, class)))
+ return(top);
+
+ if (!XQueryTree(dpy, top, &dummy, &dummy, &children, &nchildren))
+ return(0);
+
+ for (i=0; i<nchildren; i++) {
+ w = Window_With_Class(dpy, children[i], class);
+ if (w)
+ break;
+ }
+ if (children) XFree ((char *)children);
+ return(w);
+}
+
Window Select_Window_Args(Display* dpy, int screen, int* rargc, char* argv[])
{
int nargc = 1;
@@ -127,6 +152,16 @@ Window Select_Window_Args(Display* dpy, int screen, in
OPTION);
if (!w)
Fatal_Error("No window with name %s exists!",OPTION);
+ continue;
+ }
+ if (!strcmp(OPTION, "-class")) {
+ NXTOPT;
+ if (verbose)
+ printf("Selecting window by class %s\n", OPTION);
+ w = Window_With_Class(dpy, RootWindow(dpy, screen),
+ OPTION);
+ if (!w)
+ Fatal_Error("No window with class %s exists!",OPTION);
continue;
}
if (!strcmp(OPTION, "-id")) {

4
x11/xseticon/pkg-descr Normal file
View file

@ -0,0 +1,4 @@
Xterm, and likely many other X11 programs, do not set themselves window
icons, which window managers typically use to represent that program
window in switcher lists, taskbars, and so on. This program can set the
X11 window icon for any given window, to that of a given image file.