Keep track of opened terminals

I have this in my config to get a kterm at my upper left or upper right corner.

Key Up  A CM Ctrl-Alt-Up-Action
Style kterm Sticky
   DestroyFunc Ctrl-Alt-Up-Action
   AddToFunc   Ctrl-Alt-Up-Action
   + I Key Left  A A Exec kterm -bg black -fg  yellow -g +5+5
   + I Key Right A A Exec kterm -bg black -fg yellow  -g -5+5
   # optionally popup a prompt window here
   + I Schedule 5000 Key Left A A -
   + I Schedule 5000 Key Right A A -

And the same for two terms at the lover left and lower right corner.

Now i want that the same key combination shall minimize the window if its opened,
Is it possible to keep track which of my opened kterms i want to minimize, and which not.?
Or do i need to use four diffeent terminals (such as, kterm, konsole, aterm, rxvt).?
AND How do i check if a window/terminal already is opened.?
Is there a possibility check the state of a variable.?

/Dante65

Many ways. You could just set a window State for those you want to minimize. Of course, what you’re asking is to do something like:

  • Open a window if it isn’t already open.
  • Minimize (toggle) if it is.

So you want something like this:

DestroyFunc OpenOrIconify
AddToFunc   OpenOrIconify
+ I None ($0) Exec exec $0 $[1-]
+ I TestRc (Match) Break
+ I Next ($0) Iconify

Which you would call as:

OpenOrIconify xterm -fg white -bg black, ...

And as to how you would mark which windows you would or would not wish to include in this, then you can use a window State or a different name, hence ,odifying the above:

DestroyFunc OpenOrIconify
AddToFunc   OpenOrIconify
+ I Next ($0|!"SomeName1|SomeName|SomeName3") Iconify
+ I TestRc (Match) Break
+ I Exec exec $0 $[1-]
.....

Of course, this assumes you pass an appropriate -name value to the application, and the application supports it, so maybe a state would be better. Left as an exercise for you to do.

– Thomas Adam

I didn’t really understand the examples.

what i didn’t realy get is the $[-1] thing.
and this from the other OpenOrIconify

[code]

  • I Next ($0|!“SomeName1|SomeName|SomeName3”) Iconify
    [/code]This didn’t i understand

i try to pseudo translate it…to see what the more FVWM-litterated will tell.

If first parameter (the name of the window) Is Equal to SomeName1|SomeName|SomeName3, then iconify the matching one.

But - what if i want to have two windows opened.?
The only thing that happen is that the opened one get iconifyed / deicoiyied.
At least - that was what happened me, but i think it’s becaus i didn’t understand how to use it completely.

Well, i got my function to work anyway, but i am not sure i did it the right way so please can someone tell me if the examples i got from Thomas Adam is the better way to go, and please can someone point me in the right direction to understand them. .

This is what i accomplished - so far.

[code]
DestroyFunc ToggleTerm
AddToFunc ToggleTerm

  • I Next ($2) Iconify
  • I TestRc (NoMatch) Exec exec $*

Key Down A CM Ctrl-Alt-Down-Action

DestroyFunc Ctrl-Alt-Down-Action
AddToFunc Ctrl-Alt-Down-Action
#Key Down -

  • I Key Left A A ToggleTerm xterm XTerm_N_Left " -bg Khaki -fg Black -g +5-5"
  • I Key Right A A ToggleTerm xterm XTerm_N_Right " -bg Khaki -fg SaddleBrown -g -5-5"
    #+ I key Down A A ToggleTerm xterm Xterm_ScreenSession_ROOT "-bg White -fg Black -g
    60x15+150+445 -fn -fixed----20-* -e sudo screen -D -R "
  • I key Tab A A ToggleTerm xterm Xterm_ScreenSession_ROOT "-bg White -fg Black -g
    60x15+150+445 -fn -fixed----20-* -e sudo screen -D -R "
  • I Schedule 5000 Key Left A A -
  • I Schedule 5000 Key Right A A -
  • I Schedule 5000 Key Tab A A -
    #+ I Schedule 5000 Key Up A A -
    #Key Down A CM Ctrl-Alt-Down-Action
    [/code]As you see i was trying to use Down for the Xterm_ScreenSession_ROOT, but i couldn’t get it to work.
    I tried to remove the key bindings for the Up/Down Keys in the beginning of the functions to not let the it be called twice, but that didn’t help. It seems as it was called twice anyway.

And - yes i sent the most of the parameters as a string because as i unsderstand it -fvwm can’t handle more than 9 parematers (or is it ten.?)
Can there be any problem doing so.?

/Dante65
I edited the post to kep it shorter - removed the almost equal code for the Up-key, and corrected some spelling errors.

So much so, you couldn’t even quote it properly. It’s $[1-] and its all positional parameters from the second one (counting from 0) to the end.

Here – have some straws to clutch. “$0” – first parameter to function, probably window name or class. !“SomeName1|SomeName|SomeName3” – If the next window in the window ring is NOT (that’s NOT) “SomeName1” OR (that’s OR) “SomeName2” OR (that’s OR) “SomeName3”, then do something. Bears no relation to $0 at all, other than $0 expands to whatever we pass into the function.

Then open them? Your original question was selectively applying some sort of toggle to some windows – and you need to mark them in some way. You could do this using states, or names/classes, as the example above tries to show you.

Pass - and I don’t care either. I can only explain the same thing in so many ways, and so far it seems your solution doesn’t cover the original problem as you stated it. But it doesn’t matter.

– Thomas Adam

Typo-sorry

Ok, ty for the explaination.

The language barriar, sigh - i was sure i used the correct term to describe my problem.

I understand that one can be fed up with telling the same thing once and once again … I
I have spent a few days (literally) to try understand this thing, before this posting.

Is there any solution how to
use (ctrl-alt-down-down)
as i am trying to do here.?

[code]
DestroyFunc ToggleTerm
AddToFunc ToggleTerm

  • I Next ($2) Iconify
  • I TestRc (NoMatch) Exec exec $*

Key Down A CM Ctrl-Alt-Down-Action

DestroyFunc Ctrl-Alt-Down-Action
AddToFunc Ctrl-Alt-Down-Action

  • I key Down A A ToggleTerm xterm Xterm_ScreenSession_ROOT "-bg White -fg Black -g
    60x15+150+445 -fn -fixed----20-* -e sudo screen -D -R "
  • I Schedule 5000 Key Down A A -[/code]