[wiki] [official] (dwm/customization) removed obsolete stdin hacking, added rules faq || nsz

From: <hg_AT_suckless.org>
Date: Wed, 18 Feb 2009 11:59:12 +0000 (GMT)

changeset: 208:a5f248ca3a83
tag: tip
user: nsz <nszabolcs_AT_gmail.com>
date: Wed Feb 18 11:15:49 2009 +0100
files: dwm/customisation/noinput.md dwm/customisation/rules.md
description:
(dwm/customization) removed obsolete stdin hacking, added rules faq


diff -r f9c777ecb383 -r a5f248ca3a83 dwm/customisation/noinput.md
--- a/dwm/customisation/noinput.md Sun Feb 08 12:14:17 2009 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
_AT_@ -1,54 +0,0 @@
-Make standard input processing optional
-=======================================
-
-*blame [Filippo Erik Negroni](mailto:f dot e dot negroni at googlemail dot com>) about this document*
-
-**dwm** reads its standard input during its main event loop. It will then update the status bar with the contents of the standard input.
-This has the effect of blocking the program if run in the background from a terminal session: the program blocks waiting for input.
-
-If you want to run dwm in the background during an X session, and use an xterm to switch between window managers, this can be a problem.
-A small tweak to the code, without pretending to be a proper feature, is to allow `config.h` to decide whether stdin is polled or not by the main event loop, so that the user can choose to deselect the functionality for specific configurations.
-
-In `dwm.c`, if we follow the call stack, we reach the main event loop in `run()`.
-This loop manages the variable `readin`. It's value is set to True before the actual loop, and it's value is then used to determine whether stdin will be processed by `select()`.
-We can notice that the main loop will set `readin` to False if there is an error from stdin or if stdin is closed.
-
-The first change we want to carry out is within `dwm.c`:
-
-we must remove the initialisation of `readin` in the main loop
-
- _AT_@ -1219,7 +1219,6 @@
- /* main event loop, also reads status text from stdin */
- XSync(dpy, False);
- xfd = ConnectionNumber(dpy);
- - readin = True;
- offset = 0;
- len = sizeof stext - 1;
- sbuf[len] = stext[len] = '\0'; /* 0-terminator is never touched */
-
-Next, we must move the declaration and initialisation of `readin` from `dwm.c`:
-
- --- a/dwm.c Tue Jul 29 19:19:00 2008 +0100
- +++ b/dwm.c Thu Jul 31 21:47:17 2008 +0100
- _AT_@ -224,7 +224,7 @@
- [UnmapNotify] = unmapnotify
- };
- static Atom wmatom[WMLast], netatom[NetLast];
- -static Bool otherwm, readin;
- +static Bool otherwm;
- static Bool running = True;
- static unsigned int tagset[] = {1, 1}; /* after start, first tag is selected */
- static Client *clients = NULL;
-
-to `config.h`:
-
- _AT_@ -12,6 +12,7 @@
- static unsigned int snap = 32; /* snap pixel */
- static Bool showbar = True; /* False means no bar */
- static Bool topbar = True; /* False means bottom bar */
- +static Bool readin = False; /* Do not read stdin, useful for running in background */
-
- /* tagging */
- static const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
-
-This will set `readin` to False and disable readin of standard input upon startup, yet allow you to change your mind at a later stage.
diff -r f9c777ecb383 -r a5f248ca3a83 dwm/customisation/rules.md
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwm/customisation/rules.md Wed Feb 18 11:15:49 2009 +0100
_AT_@ -0,0 +1,46 @@
+Setting rules in config.h
+=========================
+
+What does `rules` do?
+---------------------
+The `rules` array is to treat certain applications (clients) in a special way.
+The window class, instance (`WM_CLASS` property) and title (`WM_NAME` property)
+can be matched to select the client. The possible actions are applying tags to
+the selected client (default is `0` which means the currently viewed tags)
+and setting the client floating (default is `False` which means tiled client).
+
+Example from the default config:
+
+ static Rule rules[] = {
+ /* class instance title tags mask isfloating */
+ { "Gimp", NULL, NULL, 0, True },
+ { "Firefox", NULL, NULL, 1 << 8, True },
+ };
+
+This makes every Gimp and Firefox window floating and makes Firefox windows
+appear on tag 9 instead of the currently viewed tags.
+
+How does the matching work?
+---------------------------
+A client is matched if its corresponding properties contain the given strings
+as substrings (case-sensitively) or `NULL` is given (which is matched on anything).
+
+The rules are matched in order, so more than one rule can be applied to a client.
+
+How to check these properties of a client?
+------------------------------------------
+The `xprop` utility can be used to get this information:
+`WM_CLASS` is (instance, class) `WM_NAME` (or `_NET_WM_NAME`) is the title.
+
+For example this shell script prints the relevant properties of the selected
+client (if the properties does not contain '`=`' or '`,`'):
+
+ xprop |awk '
+ /^WM_CLASS/{sub(/.* =/, "instance:"); sub(/,/, "\nclass:"); print}
+ /^WM_NAME/{sub(/.* =/, "title:"); print}'
+
+How to add exception to a tagging rule?
+---------------------------------------
+It cannot be simply done. For example it is difficult to achieve that each
+Firefox window goes to tag 9 except one specific dialog, which goes to tag 8,
+because the tag masks of different matched rules are 'or'ed (and not overwritten).
Received on Wed Feb 18 2009 - 12:59:12 CET

This archive was generated by hypermail 2.3.0 : Thu Sep 13 2012 - 19:30:30 CEST