Code: Select all
[Rainmeter]
Update=500
DynamicWindowSize=1
[Variables]
NetInColor=255,255,255,255
[MeasureNetworkIn]
Measure=NetIn
IfAboveValue=1023
IfAboveAction=!RainmeterSetVariable NetInColor 255,0,0,255
IfBelowValue=1024
IfBelowAction=!RainmeterSetVariable NetInColor 255,255,255,255
[MeasureDelayNetIn]
Measure=Calc
Formula=MeasureNetworkIn
[MeterNetworkIn]
Meter=String
MeasureName=MeasureDelayNetIn
W=200
H=35
X=200
Y=0
StringAlign=RIGHT
FontColor=#NetInColor#
FontSize=25
FontFace=Trebuchet MS
AntiAlias=1
NumOfDecimals=1
AutoScale=1
DynamicVariables=1
Text="%1B"
1) I set the [Variable] NetInColor=255,255,255,255 to "initialize" it to something, otherwise the first time it is used, before the first !RainmeterSetVariable happens, it will default to 0,0,0,255
2) I get the NetIn value. Dont' forget it is in bytes, not what it shows in the meter where it is autoscaled. So if it is 1k, the measure actually has 1024 in it.
3) I use IfAboveValue and IfBelowValue to execute a !RainmeterSetVariable to change the font color.
4) I then have to do a bit of a shell game. The issue is that during a single Update= cycle, the FontColor variable is set and the meter is dislpayed, but the color is always one cycle behind. Not a big deal normally, but on a network meter or a cpu meter where it jumps around a lot, the color change will be "out of sync" with the number displayed.
So we have to "delay" the display of the "number" by one cycle, so it stays in sync with the color. We do that by creating a simple calc measure that gets the value from the NetIn Measure as the "result" of a formula. Then use the value of the calc measure in the meter instead of directly using the value of the NetIn measure. That delays the display of the number in the text meter by one cycle, and the color and number will match up.
So this will display the number in white if it is below 1k, and in red if at or above 1k.