On Sat, Nov 02, 2002 at 09:04:24PM +0000, Mikhael Goikhman wrote:
> On 02 Nov 2002 11:26:30 +0100, Dominik Vogt wrote:
[snip]
> > > Currently a module that does this using perllib should be about 50 lines.
> > > It will be 30 lines (mostly grouping/sorting entries by class/resource
> > > and printing the main windowlist menu and its submenus) when automatical
> > > trackers will be ready. I will write such module as a test case later.
> > 
> > The thought of moving the WindowList functionality into a simple
> > script is appealing.  But I suspect that we will never be content
> > with the limited information that goes over the module interface.
> 
> Actually, the script will not be simple if it should implement all
> WindowList options. Especially if this is a shell script.
> 
> I fully agree that the module interface is limited, it should be enhanced
> and in some cases corrected. Still, it is pretty powerful already.

First and foremost the module interface should be *designed* and
not just export random window information as it is needed.
Especially propagating the whole window flags structure to the
modules is a serious design flaw as it implicitly declares
internal fvwm structures as part fvwm's module interface.  I don't
like that a bit and it regulary forces me to break compatibility.

> What is the script interface alternative you suggest?
> Does it use 2 pipes, in and out, just like a module?

Yes, but stdin and stdout should suffice.

> I know what you want. You want bashlib or maybe zshlib for writting fvwm
> modules in sh language.

"shlib", actually.  I always try to avoid zsh and especially bash
specifics when writing shell scripts.

> Unfortunately, sh is not a programming language.
> It depends on unix utilities that vary on different unices, even sed/awk.
> I would like to help writting such library, but it is just impossible.
> Contrary to this, you may use perl that works equally on all systems,
> even on non-unix.

Yes.  The number of portable unix commands is quite limited.
Fortunately, the user does not have to worry about it, only people
writing scripts for public use (i.e. the fvwm developers).

> > Okay, I see one very important issue here.  On one hand we have
> > the wish of the users to have more control over the WindowList (or
> > other features).  On the other hand we have the module interface
> > and the perl lib.  Now, these two do not fit together very well:
> > 
> >  - The module interface is intended for programmers, not users.
> >  - You can not rely on a working perl installation.
> >  - Only few users can program perl scripts (not me).
> 
> Writting perl is not needed any more than writting C to use FvwmButtons.

Then how do I write my own sorting algorithm using perllib without
writing perl?

> >  - /bin/sh and certain unix commands are available on every
> >    system.
> 
> Do you agree to start to use an ancient sh instead of zsh, and non GNU
> utilities (I always miss the most useful options)?

Sure.  See above.

> >  - The knowledge of writing shell scripts is much more widespread.
> 
> Sorry, I can't agree with this one. I am sure more people program C/C++
> and Perl than sh.

Yes, sure.  But I was talking about users, not programmers.  I am
quite convinced more people are able to write something like

  $ sort -t . -k 2,2 foo  # sort by extension

than writing an equivalent perl script or C program.

> It is also the most ineffective

Maybe from a point of resource usage, but don't forget ease of use.
(And module interface performance is horrible too.)

> and the less powerful.

What?!  You probably haven't seen my phone database written as a
shell script :-)

> I am also sure almost noone can write really portable large shell scripts,
> maybe except for autoconf developers. And autoconf developers moved
> to perl themselves, because text manipulation in sh is much more obscure.
> Automake developers always used perl for processing Makefile.am.
> 
> > So, in my eyes the "perl module" approach is not for the
> > typical do-it-yoursef user but for developers and very experienced
> > users/hackers.  In addition, I won't be able to help people
> > implementing their perl scripts because I never learned perl (and
> > I don't want to because of its weird syntax).
> 
> It takes years to become a perl expert, I know.
> But I am sure every programmer familar with the module interface may learn
> the basics of Perl and OOP to start to use perllib. I am willing to
> explain what test modules in tests/perl/module-* do to everyone who wants
> to learn.

Yes, I don't disagree here.  I am just thinking about an interface
that allows non-programmers to do useful things on their own.

> > The big question is:  how can we provide a powerful do-it-yourself
> > interface to the intermediate to advanced shell user?
> 
> A solution may be to maintain a powerful module for every task with all
> options users may want, so they should just choose the most suitable.
> Or a user may get the code and tweak it a bit (replace sort order).
> 
> Another solution may be to enable parts of the configuration to be shell
> commands (sorting function?). But it still will be a perl or C written
> module that just passes the relevant input to a shell script and reads and
> incorporates the output. This may be possible for very simple cases only,
> and it can't be generic, because the input/output format is very specific.

I have to think more about this.  It would not be difficult to
make up an ad hoc interface that prints the available information
into stdin of a shell script, but I wonder how useful it would be.
Let's assume we can access every style flag and each member of the
window structure with

  $[windowstruct_flag.is_transient]
  $[windowstruct_member.layer]
  $[windowstyle_flag.do_start_iconic]
  ...

(I am still thinking about a good solution to do this).  And let
us ignore the problems arising by exporting the whole window
structure as an external interface.

With that, we could add a format string that generates output and
a command that processes it to the WindowList command:

  WindowList CustomSort \
    Format=`$n $w $[page.nx] $[page.ny]` \
    Command=`/bin/sh -c 'sort -t . -k 2,2 | \
     read A B C D; \
     /bin/echo \"$A\t${C}x${D}\" WindowId $w WindowListFunc'`

(Ignore all the portability issues and bugs in the command).
Fvwm would print a line according to the format for each window
and pass that as input to a script.

Bye

Dominik ^_^  ^_^

 --
Dominik Vogt, [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [EMAIL PROTECTED]
To report problems, send mail to [EMAIL PROTECTED]

Reply via email to