Re: [dwm] dwm-5.3

From: Guillaume Quintin <coincoin169g_AT_gmail.com>
Date: Sun, 7 Dec 2008 03:44:34 +0100

On Sat, 6 Dec 2008 14:52:55 -0800
Donald Chai <donald.chai_AT_gmail.com> wrote:

>
> On Dec 6, 2008, at 10:20 AM, Guillaume Quintin wrote:
>
> > Why don't we change the way dwm gets its status text ? For example
> > we could use the SIGALRM signal to call a "spawn2" :
>
> --snip--
>
> > This will take only a few LOC, because all the reading p[0] part
> > will be in fact the reading-stdin code from the run() function which
> > will not be needed anymore. This has the advantages that one can
> > change
> > the status when dwm is running and there are no more "quitting"
> > problem. This is just an idea, forgive me not to propose some real
> > code. Well tell me what you think of this idea.
>
> I'm not sure that changing the status script when dwm is running is
> a big advantage. I'm already used to recompiling if I want to
> change any setting. :)
>
> The disadvantage of this approach is that the status script would
> have to do a lot of work to maintain any state. Most people run
> "date", "acpi" and other commands once a second, this would be fine
> for them.
>
> My status text includes the weather (updated only every 15min to
> avoid hammering their servers), and the time (updated once a minute,
> on the minute, to reduce my wakeups-per-second in PowerTOP). For
> me, this SIGALRM and spawn2 would require that I store some
> temporary data somewhere between invocations.
>
> Here's my status script in case anyone would be interested. It
> basically merges different status areas with arbitrary update
> intervals for each.
>

Then use another solution. I posted a patch some hours ago, which
requires the time.h and execute a script every second but you choose to
execute it every hour if you like you just have to modify :

int what_you_want;
t = time(0) + what_you_want;

Moreover I thought of another solution more simple for which you won't
to modify any status script or store any data between calls. It is
late, I am tired so I won't write a patch but I think we proceed as
follow :

You don't need any time.h functions. Before the main loop in the run()
function you call popen("yourscript","r");
and within the main loop, you keep select(); and fgets(); when
necessary and display it. On breaking the main loop you pclose();
Tomorrow I will try this unless someone write it during the night.

-- 
Kind regards,
Guillaume Quintin.
Received on Sun Dec 07 2008 - 02:44:34 UTC

This archive was generated by hypermail 2.2.0 : Sun Dec 07 2008 - 02:48:05 UTC