[hackers] [tabbed] Adding the -n name parameter to set WM_CLASS. Thanks Gavin Wahl || Christoph Lohmann

From: <hg_AT_suckless.org>
Date: Wed, 3 Oct 2012 07:59:29 +0200 (CEST)

changeset: 175:f923291b4237
tag: tip
user: Christoph Lohmann <20h_AT_r-36.net>
date: Wed Oct 03 07:56:53 2012 +0200
files: tabbed.1 tabbed.c
description:
Adding the -n name parameter to set WM_CLASS. Thanks Gavin Wahl
<gavinwahl_AT_gmail.com>!


diff -r 2e9d8a5c62cc -r f923291b4237 tabbed.1
--- a/tabbed.1 Mon Aug 20 09:08:09 2012 +0200
+++ b/tabbed.1 Wed Oct 03 07:56:53 2012 +0200
_AT_@ -7,6 +7,8 @@
 .RB [ \-h ]
 .RB [ \-s ]
 .RB [ \-v ]
+.RB [ \-n
+.IR name ]
 .IR [ command ... ]
 .SH DESCRIPTION
 .B tabbed
_AT_@ -23,6 +25,10 @@
 .B \-h
 will print the usage of tabbed.
 .TP
+.BI \-n " name"
+will set the WM_CLASS attribute to
+.I name.
+.TP
 .B \-s
 will disable automatic spawning of the command.
 .TP
diff -r 2e9d8a5c62cc -r f923291b4237 tabbed.c
--- a/tabbed.c Mon Aug 20 09:08:09 2012 +0200
+++ b/tabbed.c Wed Oct 03 07:56:53 2012 +0200
_AT_@ -153,6 +153,7 @@
 static int (*xerrorxlib)(Display *, XErrorEvent *);
 static char winid[64];
 static char **cmd = NULL;
+static char *wmname = "tabbed";
 
 char *argv0;
 /* configuration, allows nested code to access above variables */
_AT_@ -732,20 +733,24 @@
 setup(void) {
         /* clean up any zombies immediately */
         sigchld(0);
+
         /* init screen */
         screen = DefaultScreen(dpy);
         root = RootWindow(dpy, screen);
         initfont(font);
         bh = dc.h = dc.font.height + 2;
+
         /* init atoms */
         wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
         wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
         xembedatom = XInternAtom(dpy, "_XEMBED", False);
+
         /* init appearance */
         wx = 0;
         wy = 0;
         ww = 800;
         wh = 600;
+
         dc.norm[ColBG] = getcolor(normbgcolor);
         dc.norm[ColFG] = getcolor(normfgcolor);
         dc.sel[ColBG] = getcolor(selbgcolor);
_AT_@ -761,11 +766,14 @@
                         ButtonPressMask|ExposureMask|KeyPressMask|
                         StructureNotifyMask|SubstructureRedirectMask);
         xerrorxlib = XSetErrorHandler(xerror);
+
         XClassHint class_hint;
- class_hint.res_name = "tabbed";
- class_hint.res_class = "Tabbed";
+ class_hint.res_name = wmname;
+ class_hint.res_class = "tabbed";
         XSetClassHint(dpy, win, &class_hint);
+
         XSetWMProtocols(dpy, win, &wmatom[WMDelete], 1);
+
         snprintf(winid, sizeof winid, "%lu", win);
         nextfocus = foreground;
         focus(clients);
_AT_@ -878,7 +886,7 @@
 void
 usage(void)
 {
- die("usage: %s [-dhsv] command...\n", argv0);
+ die("usage: %s [-dhsv] [-n name] command...\n", argv0);
 }
 
 int
_AT_@ -886,22 +894,27 @@
         int detach = 0;
 
         ARGBEGIN {
+ case 'd':
+ detach = 1;
+ break;
+ case 'n':
+ wmname = EARGF(usage());
+ break;
+ case 's':
+ doinitspawn = False;
+ break;
         case 'v':
                 die("tabbed-"VERSION", © 2009-2012"
                         " tabbed engineers, see LICENSE"
                         " for details.\n");
- case 's':
- doinitspawn = False;
- break;
+ default:
         case 'h':
                 usage();
- case 'd':
- detach = 1;
- break;
         } ARGEND;
 
         if(argc < 1)
                 doinitspawn = False;
+
         setcmd(argc, argv);
 
         if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
_AT_@ -911,6 +924,7 @@
         setup();
         printf("0x%lx\n", win);
         fflush(NULL);
+
         if(detach) {
                 if(fork() == 0)
                         fclose(stdout);
_AT_@ -920,9 +934,11 @@
                         return EXIT_SUCCESS;
                 }
         }
+
         run();
         cleanup();
         XCloseDisplay(dpy);
+
         return EXIT_SUCCESS;
 }
 
Received on Wed Oct 03 2012 - 07:59:29 CEST

This archive was generated by hypermail 2.3.0 : Wed Oct 03 2012 - 08:00:18 CEST