[Solved] Periodic tasks not executed every second

I have a Time&Date script that shows hour, minutes, day and date.
The part of script that refreshes hour and minutes:

If (RemainderOfDiv (GetTime) 3600) == 0 Then Begin If $hoursFormat == {12} Then Begin ChangeTitle 2 (GetOutput {date "+%l"} 1 -1) ChangeTitle 5 (GetOutput {date "+%p"} 1 -1) End Else Begin ChangeTitle 2 (GetOutput {date "+%k"} 1 -1) ChangeTitle 5 {} End End If (RemainderOfDiv (GetTime) 60) == 0 Then ChangeTitle 4 (GetOutput {date "+%M"} 1 -1)
For most of the time it works fine, but sometimes the hour changes but the minutes remain at 59.
eg: 10:58;10:59;11:59;11:01.

Hi,

try this: [code]Init
Begin
Set $time = (GetOutput {exec date +%I:%M %P} 1 -1)
Set $date = (GetOutput {date “+%a %e %b”} 1 -1)
ChangeTitle 2 $time
ChangeTitle 5 $date
End

PeriodicTasks
Begin
If (RemainderOfDiv (GetTime) 60)==0 Then
Begin
Set $time = (GetOutput {exec date +%H:%M""} 1 -1)
Set $date = (GetOutput {date “+%a %e %b”} 1 -1)
ChangeTitle 2 $time
ChangeTitle 5 $date
End
End
:
:
[/code]I used this script in my last config (long ago). But it works fine.

Regards, TF

Hi TF,
I use different widgets for hour and minutes so I can click on them to set an alarm.

Ah, ok.

Can you post the complete FvwmScript, please?

TF

Yes, here.

Hi sebaro,

sorry for my late response, but I am very busy at the moment. I will try to test your script but I can’t say when :frowning:

TF

You can find the script with icons here http://box-look.org/content/show.php/Minimoids?content=137027.
Thanks.

Updating date doesn’t work eigther:

If (RemainderOfDiv (GetTime) 86400) == 0 Then Begin ChangeTitle 7 (GetOutput {date "+%A"} 1 -1) ChangeTitle 8 (GetOutput {date "+%d %B %Y"} 1 -1) End

Try something like:

Set $tmp = (GetOutput {exec date "+%A"} 1 -1) ChangeTitle 7 $tmp Set $tmp = (GetOutput {exec date "+%d %B %Y"} 1 -1) ChangeTitle 8 $tmp
It’s been a while since I last messed with FvwmScript but I seem to recall that calling GetOutput directly like that doesn’t work.

Is it better to use:

Set $out = (GetOutput {command} 1 -1) ChangeTitle $widget $out
instead of:

ChangeTitle $widget (GetOutput {command} 1 -1)

?

How about:

If (RemainderOfDiv (GetTime) $seconds) == 0 Then

Does it aways work?

Thanks!

I don’t think passing a function as argument to ChangeTitle works, the first way does work though as I’ve been using it for years (the timestamp on that file says it was uploaded in 2007…). There’s no need to put the widget number in a variable though.

I don’t see why not, but the way you had it originally should work as well.

If (RemainderOfDiv (GetTime) 86400) == 0 Then Begin Set $dateDay = (GetOutput {date "+%A"} 1 -1) ChangeTitle 7 $dateDay Set $dateFull = (GetOutput {date "+%d %B %Y"} 1 -1) ChangeTitle 8 $dateFull End
Doesn’t work eighter.
Maybe I should change the date when the hour is 0.

I’m still having this issue…

For my first version of the script after each second I get the minute from date’s output:

If (RemainderOfDiv (GetTime) 60) == 0 Then Set $currMinute = (GetOutput {date "+%M"} 1 -1) ChangeTitle 4 $currMinute

I thougth the script it’s not reading the date’s output fast enough.
Now I changed the script so it counts the seconds itself:

If (RemainderOfDiv (GetTime) 60) == 0 Then Set $currMinute = (Add $currMinute 1) ChangeTitle 4 $currMinute

Both versions skip minutes:
1st skips one minute and then gets the correct one from date’s output, e.g.: 11.58 - 11.59 - 12.59 - 12.01
2nd skips one minute e.g: now my two clock show, first 11:15, the other 11:16

It seems that for me the parts from “PeriodicTasks” are not executed every second.
Can this be due to my very old PC: K6-II/333MHz, 256MB RAM (FVWM 2.6.2 on Gentoo)?

Edit:
On my machine it takes more than a second to execute the periodic tasks.

Hi,

I am experiencing similar problem. I think there is a bug in function GetOutput.
For some reason it is executed only at certain interval, maybe every second or two.

When following code is executed on my laptop the output gives 100 message with the same value of nanoseconds. I would expect to have different values for every few iterations.

SingleClic :
    Begin       
     Set $i = 0 
     While $i<100 Do
       Begin
        Set $tyt = (GetOutput {exec date "+%N"} 1 -1) # get current value of nanoseconds
        Do {Exec exec xmessage "} $tyt {"}
        Set $i = (Add $i 1)
       End 

Is there any chance that someone who was involved in development of FvwmScript can help?

Regards

Henoch

Uhm … nanoseconds ? :open_mouth:

As you red in the manpage:

And this applies not to periodic tasks only I’m afraid.

FvwmScript is a simple script language which is not optimized for speed. One second is ok but faster?

Use another script language like Perl or Python to do this job. If you need information from FVWM in the script use FvwmCommand.

– Thomas –

TF,

Thanks for reply!

Actually I think you are not right:
From my little investigation it appears that SingleClic is run more often than one second.
It is run every time the click event is registered in the widget. So if you click faster than one second, which is not that difficult, than you would have equivalent number of “runs” per second.

So when you set up a script like this:

 SingleClic :
     Begin
      Set $tyt = (GetOutput {exec date "+%N"} 1 -1)
      ChangeTitle 1 $tyt
      Do {Exec exec xmessage "} $tyt {"}   
    End

You would see an xmessage window appearing after every click - a definite proof of a script runnig after every single click. But also, you would notice that GetOutput is NOT reacting that fast.
This is why I drew a conclusion that the “GetOutput” function is either buggy or is run every second or so.
Correct me if I’m wrong.

Regards

Henoch

I know that FvwmScript has some restrictions, perhaps this is one. My knowledge of the source code isn’t that good to say it’s a bug or a restriction. the best way is to ask on the FVWM mailinglist what the developers thinking. I am sorry that I cannot be of any further assistance to you. :frowning:

– Thomas –

Known limitation. No fix. Already noted by me.

– Thomas Adam

TF, Thomas,

Thanks for reply!

It would be great if this gets fixed as it appears to me that it should not be a very big deal!

Keep the good work!

H.