Battery checking and few issues with FvwmScript

Hi,

I’m using following scripts:

Main:

[code]WindowTitle {Battery}
WindowSize 24 22
Colorset 2

Init
Begin
Set $BattCritical = (GetOutput {echo “$BatteryCritical”} 1 -1)
Set $BattLow = (GetOutput {echo “$BatteryLow”} 1 -1)
Set $toggled = 0
End

PeriodicTasks
Begin
If (RemainderOfDiv (GetTime) 60)==0 Then
Begin
Set $BattPercent = (GetOutput {acpi | cut -d"," -f2 | sed -e ‘s/%//g’ | sed -e ‘s/ //g’} 1 -1)
Set $BattState = (GetOutput {acpi | cut -d"," -f1 | cut -d":" -f2 | sed -e ‘s/ //g’} 1 -1)
If $BattPercent <= $BattCritical Then
Begin
If $BattState == charging Then
Set $IconImg = {battery/CritCharge.png} # Critical battery, charging
If $BattState == discharging Then
Set $IconImg = {battery/CritDischarge.png} # Critical battery, discharging
End
Else
Begin
If $BattPercent <= $BattLow Then
Begin
If $BattState == charging Then
Set $IconImg = {battery/LowCharge.png} # Low battery, charging
If $BattState == discharging Then
Set $IconImg = {battery/LowDischarge.png} # Low battery, discharging
End
Else
Begin
If $BattState == charged Then
Set $IconImg = {battery/FullCharge.png} # Completely charged
Else
Begin
If $BattState == charging Then
Set $IconImg = {battery/GoodCharge.png} # Good battery, charging
If $BattState == discharging Then
Set $IconImg = {battery/GoodDischarge.png} # Good battery, discharging
End
End
End
If $IconImg <> $PrevIconImg Then
Begin
ChangeIcon 1 $IconImg
Set $PrevIconImg = $IconImg
End
End
End

Widget 1
Property
Type ItemDraw
Size 24 22
Position 0 0
Font “shadow=0 se:xft:Verdana:size=7:color=d5dee7”
Flags NoFocus NoReliefString
Main
Case message of
SingleClic:
Begin
If $toggled==0 Then
Begin
Set $toggled = 1
Do {Module FvwmScript scripts/BatteryPopup}
End
Else
Begin
Set $toggled = 0
Do {KillModule FvwmScript scripts/BatteryPopup}
End
End
End
[/code]

Popup:

[code]WindowTitle {BatteryPopup}
WindowSize 330 40
WindowPosition 762 20
Font “xft:Tahoma-8:bold”
Colorset 2

Init
Begin
Set $acpi = (GetOutput {acpi} 1 -1)
ChangeTitle 1 $acpi
End

PeriodicTasks
Begin
End

Widget 1
Property
Type ItemDraw
Size 330 20
Position 0 7
Flags NoFocus NoReliefString Left
Main
Case message of
SingleClic:
Begin
Do {KillModule FvwmScript scripts/BatteryPopup}
End
End[/code]

Generally, they work fine but…

Popup shows up after clicking on the icon. Is it possible to show up just if hover it? (It should works like simble hint or something)

If it’s not possible…is it to return any variable to the main script? There is a problem with var $toggled. Now I added KillModule for SingleClic in Popup…and it works, but then I have to double click on the icon to show it again (cause value $togled didn’t change after KillModule).

And one other thing in general. PeriodicTasks works every 1seconds. I need it at least every 60secs. So simple if condition fix this problem. But the fact that FvwmScript checks every 1s, I get usually 3 wake-ups for my CPU from FvwmScript, just for nothing. Is it possible to custom PeriodicTasks function without recompilation of this module?

Not at the moment, no.

Not as such. You would need to somehow store this in a file which would be read in.

It’s not possible to custom PeriodicTasks.

– Thomas Adam