zsh-users
 help / color / mirror / code / Atom feed
From: Dominik Vogt <dominik.vogt@gmx.de>
To: zsh-users@zsh.org
Subject: Re: Determining the length of "long"?
Date: Fri, 12 Sep 2014 19:50:02 +0100	[thread overview]
Message-ID: <20140912185002.GA4132@gmx.de> (raw)
In-Reply-To: <20140912181019.GZ4075@isis.sigpipe.cz>

On Fri, Sep 12, 2014 at 08:10:19PM +0200, Roman Neuhauser wrote:
> # dominik.vogt@gmx.de / 2014-09-12 19:04:44 +0200:
> > > see getconf(1)[0] and unistd.h(0P)[1], specifically
> > > _POSIX_V6_ILP32_OFF32 and its brethren.
> > 
> > Ah great, that pointed exactly to what I need.
> 
> glad to be of help!  i would have brought these up earlier but you said
> 
> > inside a zsh script (without using external programs, of course).
> 
> which seemed to disqualify getconf(1)...  the clarification was also
> very subtle: :)

I know.  :-)  But I'm not immune to learning when a certain
approach causes more trouble than it saves you.  Actually I didn't
know a simple configuration program was around and wanted to avoid
using a monster like perl or gcc, because latency does matter.

> > the shell is absolutely the right tool here (combine several unix
> > command line programs in a pipe, filter their output and generate
> > a wm command from that)
>
> overall a good reminder of the need for precise problem statements. :)

Yes, but easy to say afterwards when one already know the solution. :)

What the script actually does is:

 * When started by fvwm it is passed an input and an output file
   descriptor to receive and send data from and to the wm core as
   numbers on the command line.  (The direction from fvwm to the
   script is disabled in that case).
 * Then, and that is the new feature, it determines automatically
   if binary longs are 32 bit or 64 bit and chooses a function
   to send strings to fvwm.  (The length of the string is sent as
   a binary long value which is hard coded to 160.)
 * Then it goes into an endless loop and sleeps for a while with
   zselect.  When it wakes up it

    * calls ps to determine the process that uses the most cpu
    * extracts the used memory percentage prom /proc/meminfo
    * uses strftime to get the current time and date in a certain
      format

   All this information is wrapped in wm commands and sent to the
   window manager core which forwards it to another module
   (FvwmButtons) which in turn updates the labels of some buttons
   to these strings.

As I always have a plethora of zshs running anyway, this approach
turned out to be very easy to implement, and does not use much
resources.  In earlier attempts to get this right there was a
noticeable lag, say, when playing kobodeluxe.

Eventually we'll make the fvwm module interface easier to use and
then it won't be necessary to determine details of the machine
architecture anymore.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt


      reply	other threads:[~2014-09-12 18:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-11 21:36 Dominik Vogt
2014-09-12  2:58 ` Kurtis Rader
2014-09-12  4:39 ` Bart Schaefer
2014-09-12  8:42   ` Dominik Vogt
2014-09-12 13:17     ` Kurtis Rader
2014-09-12 23:16     ` Bart Schaefer
2014-09-12 23:42       ` Dominik Vogt
2014-09-13  0:17         ` Bart Schaefer
2014-09-12  8:51   ` Peter Stephenson
2014-09-12 16:17 ` Roman Neuhauser
2014-09-12 17:04   ` Dominik Vogt
2014-09-12 18:10     ` Roman Neuhauser
2014-09-12 18:50       ` Dominik Vogt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140912185002.GA4132@gmx.de \
    --to=dominik.vogt@gmx.de \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).