Discussion:
FVWM: (Icon)TitleFormat doesnt quite work like IndexedWindowName for one window
elliot s
2011-10-19 17:51:59 UTC
Permalink
Version 2.6.3:
Previous versions only added the "(%t)" when there was a repeated name.
The new code always adds it.
I worked around the %t in add_window.c by checking if count was
non-zero, tho that wouldnt kill the parens, which i changed to a space
in my fvwmrc.
Thomas Adam
2011-10-20 08:13:34 UTC
Permalink
Post by elliot s
Previous versions only added the "(%t)" when there was a repeated name.
The new code always adds it.
This is not a bug, but rather very much by deliberate design. The old logic
tried to do this before but failed, and when I refactored everything I
fixed it. So this is how it's going to be with %t from now on.

-- Thomas Adam
Harry portobello
2011-10-23 17:48:01 UTC
Permalink
Post by elliot s
Previous versions only added the "(%t)" when there was a repeated name.
The new code always adds it.
This is not a bug, but rather very much by deliberate design.  The old logic
tried to do this before but failed, and when I refactored everything I
fixed it.  So this is how it's going to be with %t from now on.
i too liked the original behavior. Can you add it back please? Its not
good that you reimplement features and remove functionality at the
same time. How is this not a bug precisely?

Harry
John Latham
2011-10-24 03:54:22 UTC
Permalink
Post by Harry portobello
Post by elliot s
Previous versions only added the "(%t)" when there was a repeated name.
The new code always adds it.
This is not a bug, but rather very much by deliberate design. =A0The old =
logic
tried to do this before but failed, and when I refactored everything I
fixed it. =A0So this is how it's going to be with %t from now on.
i too liked the original behavior. Can you add it back please? Its not
good that you reimplement features and remove functionality at the
same time. How is this not a bug precisely?
It would seem you have not read the man page! ;-)

Thank you Thomas for, yet again, fixing a bug so that fvwm behaves as
specified.
Harry portobello
2011-10-29 11:37:04 UTC
Permalink
hullo,
Post by elliot s
Previous versions only added the "(%t)" when there was a repeated name.
The new code always adds it.
I worked around the %t in add_window.c by checking if count was
non-zero, tho that wouldnt kill the parens, which i changed to a space
in my fvwmrc.
the patch with this email i have written stops the number of window if
it is 1 - but what must i do to delete the brackets?

i do not like the new titleformat command because this is now very hard to do

Harry
Thomas Adam
2011-10-29 12:18:29 UTC
Permalink
Post by Harry portobello
hullo,
Post by elliot s
Previous versions only added the "(%t)" when there was a repeated name.
The new code always adds it.
I worked around the %t in add_window.c by checking if count was
non-zero, tho that wouldnt kill the parens, which i changed to a space
in my fvwmrc.
the patch with this email i have written stops the number of window if
it is 1 - but what must i do to delete the brackets?
The parenthesis are only by default if you explicitly use IndexedWindowName.
If you use TitleFormat directly, you're free to add whatever you want around
%t.

I'm still not going to fix this; there is nothing broken.

-- Thomas Adam
--
"Deep in my heart I wish I was wrong. But deep in my heart I know I am
not." -- Morrissey ("Girl Least Likely To" -- off of Viva Hate.)
Michael Großer
2011-10-29 20:38:36 UTC
Permalink
Post by Thomas Adam
Post by Harry portobello
hullo,
Post by elliot s
Previous versions only added the "(%t)" when there was a repeated name.
The new code always adds it.
I worked around the %t in add_window.c by checking if count was
non-zero, tho that wouldnt kill the parens, which i changed to a space
in my fvwmrc.
the patch with this email i have written stops the number of window if
it is 1 - but what must i do to delete the brackets?
[...]
Post by Thomas Adam
I'm still not going to fix this; there is nothing broken.
Maybe, Harry should politely ask for a new feature?
If there are people who need such kind of behaviour, then
the specification could be extended with a new option, maybe
a switch?
Thomas Adam
2011-10-29 21:08:07 UTC
Permalink
Post by Michael Großer
Post by Thomas Adam
Post by Harry portobello
hullo,
Post by elliot s
Previous versions only added the "(%t)" when there was a repeated name.
The new code always adds it.
I worked around the %t in add_window.c by checking if count was
non-zero, tho that wouldnt kill the parens, which i changed to a space
in my fvwmrc.
the patch with this email i have written stops the number of window if
it is 1 - but what must i do to delete the brackets?
[...]
Post by Thomas Adam
I'm still not going to fix this; there is nothing broken.
Maybe, Harry should politely ask for a new feature?
If there are people who need such kind of behaviour, then
the specification could be extended with a new option, maybe
a switch?
It's a count -- the number of windows matching a condition. It was a bug in
the original that it never put the number 1 there for a single instance.
Adding in a flag is confusing and rather amusing to document why. If you
*really* can't live without this, script it with FvwmEvent.

-- Thomas Adam
--
"Deep in my heart I wish I was wrong. But deep in my heart I know I am
not." -- Morrissey ("Girl Least Likely To" -- off of Viva Hate.)
Harry portobello
2011-10-30 20:09:52 UTC
Permalink
Post by Michael Großer
Post by Thomas Adam
Post by Harry portobello
hullo,
Post by elliot s
Previous versions only added the "(%t)" when there was a repeated name.
The new code always adds it.
I worked around the %t in add_window.c by checking if count was
non-zero, tho that wouldnt kill the parens, which i changed to a space
in my fvwmrc.
the patch with this email i have written stops the number of window if
it is 1 - but what must i do to delete the brackets?
[...]
Post by Thomas Adam
I'm still not going to fix this; there is nothing broken.
Maybe, Harry should politely ask for a new feature?
If there are people who need such kind of behaviour, then
the specification could be extended with a new option, maybe
a switch?
It's a count -- the number of windows matching a condition.  It was a bug in
the original that it never put the number 1 there for a single instance.
Adding in a flag is confusing and rather amusing to document why.  If you
*really* can't live without this, script it with FvwmEvent.
How do i do this with FvwmEvent? Thanks..

Harry
Thomas Adam
2011-10-30 20:51:01 UTC
Permalink
Post by Harry portobello
How do i do this with FvwmEvent? Thanks..
Something like:

DestroyFunc CountWindow
AddToFunc CountWindow
+ I SetEnv WindowCount 0
+ I All ($[w.class], !Transient) PipeRead \
`echo SetEnv WindowCount $$$$(($$$$WindowCount + 1))`
+ I PipeRead `[ $WindowCount = 1 ] && echo \
"WindowStyle TitleFormat %n" || echo "Nop"`
+ I UnsetEnv WindowCount

DestroyModuleConfig FE-tweakttformat
*FE-tweakttformat: add_window CountWindow

AddToFunc StartFunction I Module FvwmEvent FE-tweakttformat

Change to suit your needs. I have not tested this myself.

-- Thomas Adam
--
"Deep in my heart I wish I was wrong. But deep in my heart I know I am
not." -- Morrissey ("Girl Least Likely To" -- off of Viva Hate.)
Harry portobello
2011-10-31 00:33:00 UTC
Permalink
hullo,
Post by Harry portobello
How do i do this with FvwmEvent? Thanks..
   DestroyFunc CountWindow
   AddToFunc   CountWindow
   + I SetEnv WindowCount 0
   + I All ($[w.class], !Transient) PipeRead \
       `echo SetEnv WindowCount $$$$(($$$$WindowCount + 1))`
   + I PipeRead `[ $WindowCount = 1 ] && echo \
       "WindowStyle TitleFormat %n" || echo "Nop"`
   + I UnsetEnv WindowCount
   DestroyModuleConfig FE-tweakttformat
   *FE-tweakttformat: add_window CountWindow
   AddToFunc StartFunction I Module FvwmEvent FE-tweakttformat
Change to suit your needs.  I have not tested this myself.
this works but is complex. can you tell me how it works? would be nice
still for such things to be part of %t for titleformat

Harry
Michael Großer
2011-10-31 04:36:10 UTC
Permalink
Post by Thomas Adam
`echo SetEnv WindowCount $$$$(($$$$WindowCount + 1))`
Nice to see that there is an alternative way to perform
calculations without the use of bc. This idea could eliminate
a dependency of my FVWM scripts ;-)
Thomas Adam
2011-10-31 09:17:14 UTC
Permalink
Post by Harry portobello
hullo,
Post by Harry portobello
How do i do this with FvwmEvent? Thanks..
   DestroyFunc CountWindow
   AddToFunc   CountWindow
   + I SetEnv WindowCount 0
   + I All ($[w.class], !Transient) PipeRead \
       `echo SetEnv WindowCount $$$$(($$$$WindowCount + 1))`
   + I PipeRead `[ $WindowCount = 1 ] && echo \
       "WindowStyle TitleFormat %n" || echo "Nop"`
   + I UnsetEnv WindowCount
   DestroyModuleConfig FE-tweakttformat
   *FE-tweakttformat: add_window CountWindow
   AddToFunc StartFunction I Module FvwmEvent FE-tweakttformat
Change to suit your needs.  I have not tested this myself.
this works but is complex. can you tell me how it works? would be nice
still for such things to be part of %t for titleformat
It works like this; although I should point out that what I am about to
detail to you has little to do with FVWM and more generally about basic
shell constructs.

DestroyFunc CountWindow
AddToFunc   CountWindow

Destroys and recreates a function named CountWindow.

   + I SetEnv WindowCount 0

Sets up an environment variable called WindowCount which we initially set to
zero [1].

   + I All ($[w.class], !Transient) PipeRead \
       `echo SetEnv WindowCount $$$$(($$$$WindowCount + 1))`

This does all of the work for us. Note that here, $[w.class] expands to the
window's class, which we're using as a reference point to count all windows
of this type. There's two things going on here which you should be aware
of:

* We don't pass in the window name. This is because when CountWindow is
called via FvwmEvent, it's already running in the window context of the
window which had the action. Since we're using add_window, each window
that is mapped is referenced without us needing to track it manually.

* We're using the window ring to go through all windows, looking for ones
match the class name, as well as those which are not transient. It is not
enough in this context to initially use the window's WM_NAME or resource,
as they can change, and you wanted an accurate count, so...

Then we call PipeRead to put us in a shell -- perform some expression with
it, and then tell FVWM to do something. This will be called once per match
from the All command, and all we're doing here is incrementing the value
stored in $[WindowCount] each time.

   + I PipeRead `[ $WindowCount = 1 ] && echo \
       "WindowStyle TitleFormat %n" || echo "Nop"`

Having collected all of that, we then check to see how many instances of
that window exist. If there's only one instance of such a window we've just
mapped, then we set its TitleFormat to just %n; otherwise we ask FVWM to do
nothing (Nop). By using a Nop, we ensure that for all other cases, the
TitleFormat used via usual Style conditions are met instead. This means
any window with a count here > 1, will be counted by %t in the usual way.

   + I UnsetEnv WindowCount

Since we're now done with what we need, clear out the WindowCount
environment variable.

   DestroyModuleConfig FE-tweakttformat
   *FE-tweakttformat: add_window CountWindow

This destroys and creates a new module alias called FE-tweakttformat, which
we'll be asking FvwmEvent to look after. In this instance, we're only
interested in newly-created windows, hence we've defined the add_window
event, which will call out CountWindow function whenever new windows are
mapped.

   AddToFunc StartFunction I Module FvwmEvent FE-tweakttformat

Finally, we'll ask FVWM to start FvwmEvent with this module alias when it
starts up at init, and again should we restart FVWM.

HTH,

-- Thomas Adam

[1] Using environment variables in this way is useful; the persistency of
this value is cleared at the end of the function -- a very *good* use of
SetEnv here. But people forget to clear out the environment variable
afterwards, cluttering up the environment with stale information.
Loading...