When I click on a FvwmScript widget, I want to either execute a new (and different) FvwmScript or, if that new and different FvwmScript has previously been executed, close it. I believe that I have to use LaunchScript but I don’t quite understand how.
Right now, my code is simply:
SingleClic:
Begin
Do {FvwmScript scripts/Calendar}
End
which obviously just launches the new FvwmScript everytime.
I tried
Do {LaunchScript scripts/Calendar}
but that didn’t work. Any ideas?
Thanks.
Just set a valiable and check that. Eg, when your first script has been executed do something like
Set $toggled=1
and set it back to 0 when you toggle again.
And to check if your script has already been run:
If $toggled==1 Then
Begin
#kill the first script and execute your second script
Set $toggled=0 #reset toggled
End
Else
Begin
#run the first script and kill the second one
Set $toggled=1 #set toggled
End
This is the same general principle as you’d use inside your main Fvwm configuration file, which is described here.
Thanks TBD, I don’t know why the simple way didn’t occur to me. I’m having trouble with the killing part of the script though. Right now I have:
If $toggled==0 Then
Begin
Set $toggled = 1
Do {FvwmScript scripts/Calendar}
End
Else
Begin
Set $toggled = 0
SendToScript Calendar Quit
End
When I click on the time widget, the Calendar script executes, but nothing happens on every subsequent click (nor does the visible Calendar script quit). If I comment out the SendToScript line, every other click causes the Calendar to pop up like I want. So I’m pretty sure I’m not using SendToScript correctly - what is the correct syntax?
You need to use LaunchScript to launch the script, you need the ID it returns to be able to refer to the script with SendToScript, see the FvwmScript manpage for details on it’s use.
A-ha! I’m almost there, although the SendToScript line still isn’t working. I have:
If $toggled==0 Then
Begin
Set $toggled = 1
Set $CalID = (LaunchScript {scripts/Calendar})
End
Else
Begin
Set $toggled = 0
SendToScript $CalID {Quit}
End
I’ve checked and $CalID has the correct value. I’ve even tried something simple like “SendToScript $CalID {ChangeTitle 1 “test”}” and that did nothing as well. I’m pretty sure I have the right syntax according to the man pages…?
I appreciate your help and patience with this, TBD.