[wiki] [upstream] Added customisation that allows user to switch reading of stdin on/off via config.h || f

From: <hg_AT_suckless.org>
Date: Thu, 31 Jul 2008 22:00:32 +0100 (BST)

changeset: 99:65917a2f6edb
tag: tip
user: f.e.negroni_AT_gmail.com
date: Thu Jul 31 22:00:31 2008 +0100
files: dwm/customisation/noinput.md
description:
Added customisation that allows user to switch reading of stdin on/off via config.h


diff -r 97c204d95d1a -r 65917a2f6edb dwm/customisation/noinput.md
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwm/customisation/noinput.md Thu Jul 31 22:00:31 2008 +0100
_AT_@ -0,0 +1,52 @@
+Make standard input processing optional
+=======================================
+
+**dwm** reads its standard input during its main event loop. It will then update the statur 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.
Received on Thu Jul 31 2008 - 23:00:32 CEST

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