Hi All,
I totally rewrote the simple ACPI battery monitor I had in previous Configs for FreeBSD and to work with nice 64x64 PNG images. Here’s the FvwmScript:
[code]WindowTitle {FvwmApplet-Batt}
WindowSize 64 64
WindowPosition 0 0
Init
Begin
Set $MainColor=(GetScriptArgument 1)
If $MainColor <> {} Then
Begin
ChangeColorset 0 $MainColor
ChangeColorset 1 $MainColor
End
Set $batt = (GetOutput {exec sysctl -n hw.acpi.battery.life} 1 -1)
Set $ac = (GetOutput {exec sysctl -n hw.acpi.acline} 1 -1)
# three possibilities for battery percentage:
If $batt < 50 Then
Set $icon = {ic_batt_low}
Else
Begin
If $batt < 75 Then
Set $icon = {ic_batt_med}
Else
Begin
Set $icon = {ic_batt_full}
End
End
# we're working on battery level now.
If $ac == 1 Then
Set $icon = $icon {_on.png}
Else
Begin
Set $icon = $icon {.png}
End
ChangeIcon 1 $icon
ChangeTitle 1 $batt
End
PeriodicTasks
Begin
If (RemainderOfDiv (GetTime) 60) == 0 Then
Begin
Set $batt = (GetOutput {exec sysctl -n hw.acpi.battery.life} 1 -1)
Set $ac = (GetOutput {exec sysctl -n hw.acpi.acline} 1 -1)
# three possibilities for battery percentage:
If $batt < 50 Then
Set $icon = {ic_batt_low}
Else
Begin
If $batt < 75 Then
Set $icon = {ic_batt_med}
Else
Begin
Set $icon = {ic_batt_full}
End
End
# we're working on battery level now.
If $ac == 1 Then
Set $icon = $icon {_on.png}
Else
Begin
Set $icon = $icon {.png}
End
# apply the new icon.
ChangeIcon 1 $icon
ChangeTitle 1 $batt
End
End
Widget 1
Property
Type ItemDraw
Size 64 64
Position 0 0
Flags NoFocus NoReliefString
Main
Case message of
SingleClic:
Begin
Do {exec speedstepmode}
End
End[/code]
Of course it works perfectly (hehe) but I have a question. I would like something like a “OnMouseHover” function, as soon as I move my mouse to the script current icon, I would like the script to generate a popup above the icon with the current $batt / $ac value. Tried a couple of things but none work. Is it even possible?
What IS possible: (right)clicking executes another FvwmScript where a label is created using $batt as an argument. But that’s not exactly what I would like…
i’m no hero at FvwmScript but did fairly well, any help is appreciated!