Subject: patch: special conditions matching selectively name, icon name or class, resource

From: Markus Schwarzenberg <[email-masked]>
Date: Wed, 21 Apr 2004 09:48:48 +0200

Hello,

for a long time I've been using a small patch to fvwm 2.4.8, (which now 
is adopted to 2.4.18 and 2.5.10, too) and would like to ask if other people
find it usefull too (so it could be included into the fvwm source one day):

Description:

  The patch adds the following syntax to Condition checks to selectively
  select a match (or mismatch) of a name, icon name, resource name or class:

	%r==RESOURCE
        %c==CLASS
	%i==ICONNAME
        %n==NAME

	%r!=RESOURCE
        %c!=CLASS
	%i!=ICONNAME
        %n!=NAME
  
With this patch it's possible to implement the following:

    AddToFunc FocusAndRaise 
    + "I" Focus
    + "I" Raise

    AddToFunc CycleFunc
    + I Current (%c==Maker)                    $0 (%c==Maker,$1) $2
    + I Current (%c==Gimp)                     $0 (%c==Gimp,$1) $2
    + I Current (%c==Sylpheed)                 $0 (%c==Sylpheed,$1) $2
    + I Current (%c==MiXViews)                 $0 (%c==MiXViews,$1) $2
    + I Current (%c==Zmail)                    $0 (%c==Zmail,$1) $2
    + I Current (%c==XTerm %r==RTerm)          $0 (%c==XTerm,%r==RTerm,$1) $2
    + I Current (%c==XTerm %r==TMan)           $0 (%c==XTerm,%r==TMan,$1) $2
    + I Current (Ddd*)                         $0 (Ddd*,$1) $2
    + I Current (%c==XTerm %r==Ddd)            $0 (%c!=XTerm,Ddd*,$1) $2
    + I Current (%c==XTerm %r!=RTerm %r!=TMan %r!=Ddd)  $0 (%c==XTerm,%r!=RTerm,%r!=TMan,%r!=Ddd,$1) $2
    + I Current (%c!=XTerm %c!=Zmail %c!=Ddd %c!=Gimp %c!=Maker %c!=Sylpheed %c!=MiXViews) $0 (%r==$r,$1) $2

    Key "w" WFST  4 Current CycleFunc Next !Iconic,CurrentDesk FocusAndRaise
    Key "w" WFST S4 Current CycleFunc Prev !Iconic,CurrentDesk FocusAndRaise

thus giving a possibility to cycle trough the windows of the currently focused 
application, where the application is selected on its resource or class 
(depending: some apps, for example the gimp or sylpheed, use the same class 
for all of their windows, where most other applications are using the same 
resource for all of their windows).
False matches with a random title or icon name, or missing matches are avoided 
which seems impossible in practice using simpler methods like

  AddToFunc SimpleCycleFunc
  + I Current ($r)                    $0 ($r,$1) $2

  Key "w" WFST  4 Current SimpleCycleFunc Next !Iconic,CurrentDesk FocusAndRaise

The patch has been written since I didn't see a simple way to implement this
functionality (bound in the example above to "w" + (Shift) Mod4), at least not
without having to invoke external programs. 

I don't care much about the current syntax. So if people would like (and 
incooporate) the patch feel free to make improvement suggestions.

The patch has been tested successfully with fvwm 2.4.8 for more than a year 
(8 hours per day usage) and fvwm 2.5.10 for about two weeks.

Markus Schwarzenberg

Attachments: patches (diff -u) for fvwm 2.4.18 and 2.5.10

---

From: Mikhael Goikhman <[email-masked]>
Date: Wed, 21 Apr 2004 21:26:13 +0000

>   select a match (or mismatch) of a name, icon name, resource name or class:

IMO the syntax should be more readable:

  ThisWindow (Class XTerm, !Resource RTerm, !Resource ATerm) Beep

and not:

  ThisWindow (%c==XTerm %r!=RTerm %r!=ATerm) Beep

Regards,
Mikhael.
--
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-masked].
To report problems, send mail to [email-masked]

---

From: Markus Schwarzenberg <[email-masked]>
Date: Thu, 22 Apr 2004 10:10:20 +0200

On Wed, 21 Apr 2004 21:26:13 +0000 Mikhael Goikhman <[email-masked]>
wrote:

> > for a long time I've been using a small patch to fvwm 2.4.8, (which
> > now is adopted to 2.4.18 and 2.5.10, too) and would like to ask if
> > other people find it usefull too (so it could be included into the
> > fvwm source one day):
> > 
> > Description:
> > 
> >   The patch adds the following syntax to Condition checks to
> >   selectively select a match (or mismatch) of a name, icon name,
> >   resource name or class:
> > 
> > 	%r==RESOURCE
> >         %c==CLASS
> > 	%i==ICONNAME
> >         %n==NAME
> > 
> > 	%r!=RESOURCE
> >         %c!=CLASS
> > 	%i!=ICONNAME
> >         %n!=NAME
> 

This would introduce more ambiguousness, since conditions still may 
be separated by whitespaces or commas. In the example above it's not
clear how to interpret "Class": Is it a window name, icon name, 
class name or resource name or a special match identifier?

The syntax proposed by you would be OK if whitespaces were
abolished as condition separators.

Markus Schwarzenberg

---

From: Mikhael Goikhman <[email-masked]>
Date: Thu, 22 Apr 2004 10:59:21 +0000

> class name or resource name or a special match identifier?

I don't think there is any ambiguousness, just always interpret strings
"Class" and similar specially. This does not introduce any problem if a
user uses comma (preferred and hopefully the only syntax in the future).
We already use special keywords in conditions: State, Layer. In any case,
this is less ambiguous than to interpret substrings '%', '==' and '!='
in names specially.

> abolished as condition separators.

This is a long-term intention for all commands. Commas are only optional
if there is no ambiguity, otherwise they are mandatory. I don't oppose to
issue warnings when commas are missing.

Regards,
Mikhael.