WindowTitle {FvwmScript-Clock}
WindowSize 172 24 # Size
WindowPosition 0 0 # Position
Colorset 10
Init
Begin
Set $Hour=(GetOutput {date '+%a %d %b %y - %H:%M'} 1 -1)
Set $ThemeFont = (GetOutput {echo $ThemeFont} 1 -1)
ChangeTitle 1 $Hour
End
PeriodicTasks
Begin
If (RemainderOfDiv (GetTime) 1)==0 Then
Begin
Set $Hour=(GetOutput {date '+%a %d %b %y - %H:%M'} 1 -1)
Set $ThemeFont = (GetOutput {echo $ThemeFont} 1 -1)
ChangeTitle 1 $Hour
End
End
Widget 1
Property
Size 172 24
Position 0 0
Font $ThemeFont
Type ItemDraw
End
The ThemeFont variable is readed and the script can see it with no problem (I checked changing $Hour by $ThemeFont in the ChangeTitle sentence), but the command Font seems not capable to expand variables, am I wrong?
In the console I just get a message telling me that the script cannot find the font “$ThemeFont”, so it seems as it can’t expand variables, or am I missing something? Im pretty new to FvwmScript so just bear with me
Ah! As always, five minutes after my post I found a working solutions
WindowTitle {FvwmScript-Clock}
WindowSize 172 24 # Size
WindowPosition 0 0 # Position
Colorset 10
Init
Begin
Set $AHour=(GetOutput {date '+%a %d %b %y - %H:%M'} 1 -1)
Set $ThemeFont = (GetOutput {echo $ThemeFont} 1 -1)
ChangeFont 1 $ThemeFont
ChangeTitle 1 $AHour
End
PeriodicTasks
Begin
If (RemainderOfDiv (GetTime) 1)==0 Then
Begin
Set $AHour=(GetOutput {date '+%a %d %b %y - %H:%M'} 1 -1)
ChangeTitle 1 $AHour
End
End
Widget 1
Property
Size 172 24
Position 0 0
Type ItemDraw
End
What I do is to change the widget font in the initialization part. The problem is that now the colorset seems weird and there is a bit of flickering now and then, but that is another topic I suppose. I will post any new advance.
EDIT: The flickering was due to a boog in the script (it checked remainder of time/1, so every seccond, that with a truetype font is not a good idea, at least on my box). The weird colors was due to the fact that the font in $ThemeFont var had a shadow included into the string, I just changed the colorset and all is fine now. Topic solved.
What I did for the flicker part is to break the time into two parts, one for
the hour, the other for the minute. So every minutes, only 1 or 2 digits get
changed, and that almost eliminate the flickering.
At least in my case, even with no checks it still flickers:
PeriodicTasks
Begin
Set $AHour=(GetOutput {date '+%H %M %S'} 1 -1)
ChangeTitle 1 $AHour
End
The only workable solution here for now is to use bitmap fonts. That works smooth, of course, the aspects is not the same that you could archieve with a ttf font, but I preffer having a normal font and no flickers at all.
If you’re only showing hours and minutes, do you really need it to be exact to the second? Maybe only update the time every 15 or 30 or even 60 seconds… That will help with the flickering.
Well, the seconds are not a problem, but I like to have the two dots effect, because when Im doing weird things I relly on that to check if the box has hanged (not that that happen too often though).
I use this:
PeriodicTasks
Begin
If (RemainderOfDiv (GetTime) 2)==0 Then
Begin
Set $AHour=(GetOutput {date '+%H %M %S'} 1 -1)
ChangeTitle 1 $AHour
End
Else
Begin
Set $AHour=(GetOutput {date '+%H:%M:%S'} 1 -1)
ChangeTitle 1 $AHour
End
Set $ADate=(GetOutput {date '+%d/%m/%y'} 1 -1)
ChangeTitle 2 $ADate
End
Wich works fine with --terminus-medium-.
Anyway, yes, you are right in one matter: if you update the clock once every minute the flickering is not so annoying, but that is because there is no redraw, the second that the thing redraws the clock still flickers. This is clearly a problem of FvwmScript with truetype fonts (all the clocks over the world that support tff can do well with them).
I finally dropped the seconds and the bliking bots and the thing goes smooth. Anyway, to use the $S string I would need some sed processing (or to hava a bery big clock), which I dont think would be better in any way.
Ok. I did it myself. By reducing the number of digit to refresh every seconds, the flicker is almost gone. ( As I said before )
The clock ( 11/24 19:34:52 ) is broken into 3 parts, each is a Widget:
Date, 11/24
Hour and Minute, 19:34:
Seconds, 52
Only Widget 3 needs update every second, and it has only 2 digits.
Here is the code:
Init
Begin
Set $tmp = (GetOutput {exec date "+%m/%d"} 1 -1)
ChangeTitle 1 $tmp
Set $tmp = (GetOutput {exec date "+%H:%M:"} 1 -1)
ChangeTitle 2 $tmp
Set $sec0 = (GetOutput {exec date "+%S"} 1 -1)
ChangeTitle 3 $sec0
End
PeriodicTasks
Begin
Set $sec1 = (GetOutput {exec date "+%S"} 1 -1)
If $sec1 > $sec0 Then
Begin
ChangeTitle 3 $sec1
End
If $sec1 < $sec0 Then
Begin
ChangeTitle 3 $sec1
Set $tmp = (GetOutput {exec date "+%H:%M:"} 1 -1)
ChangeTitle 2 $tmp
If $tmp == {00:00:} Then
Begin
Set $tmp = (GetOutput {exec date "+%m/%d"} 1 -1)
ChangeTitle 1 $tmp
End
End
Set $sec0 = $sec1
End