I have a fvwmscript that displays an icon. When I click on it, it opens a terminal and starts a program in it.
If I click on it again, it starts the program again. This is not what I want.
I want the script to check if the window is already open. If it is already open, it should raise the window, otherwise it should start the program.
how do I check if a certain window already exists?
Of course it works – I suspect your script is flawed. Here’s a contrived
example:
WindowTitle {PressMeExample}
WindowSize 100 32
Font "xft:monospace:size=12"
Init
Begin
End
Widget 1
Property
Size 34 6
Position 1 1
Flags NoReliefString
Type PushButton
Title {Press Me}
Main
Case message of
SingleClic :
Begin
Do {FvwmTitleRxvt}
End
End
End
Note the Do {} command is bound inside the single click of the button
widget. The function it is calling looks like this:
DestroyFunc FvwmTitleRxvt
AddToFunc FvwmTitleRxvt
+ I Exec exec rxvt
If you’re still having problem, paste your entire script, and not some
random portion you think might pertain to your problem. In isolating the
area you think is not working, you’re not putting it into its in-situ
context.
ok, got it almost working. There was a typo somewhere
The application now only opens if it is not open already. But when I click on the button again, the program should be raised (or closed) but that doesn’t seem to work.
this is the function:
DestroyFunc showplaylist
AddToFunc showplaylist
+ I Any (ncmpc, CurrentDesk) Raise
+ I TestRc (NoMatch) None (ncmpc, CurrentDesk) Exec exec $[TermName] -tr -bg black -fg white -trsb -sh 45 +sb -e ncmpc -m
it is being called via a Do{showplaylist} is a fvwmscript
I have no idea why it doesn’t work. In case it does matter, I use 4 desks of 1 page.
if I switch to another desk while ncmpc is open, it is opened again on the other desk. can this be changed to move the already existing instance to the other desk?
The “problem” is with “Any” which runs in a different context. Change it to “All”. (It runs in the context of the root window, so it might not do what you want it to).