It is currently March 29th, 2024, 1:03 am

Rainmeter starts before Network

Tips and Tricks from the Rainmeter Community
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Rainmeter starts before Network

Post by jsmorley »

While unusual, it is possible that Rainmeter could load before Windows is done establishing internet connectivity. This is slightly more likely if you are on a WiFi connection. Since most WebParser measures are going to have a default UpdateRate of 600, or every 10 minutes, your skins can sit for up to 10 minutes with no values until the next time they head out to the internet. You obviously don't want that. Refreshing manually once your internet becomes active will poke them, but that is annoying and ugly.

While you can't really have Rainmeter "wait" for network connectivity to load, you can have it detect that there is a connection to the Internet ,and automatically refresh all skins once that happens.

You can load a skin like this:
NetworkBoot_1.0.rmskin

Code: Select all

[Rainmeter]
Update=100

[MeasureOnLoad]
Measure=Calc
Formula=Counter
IfEqualValue=1
IfEqualAction=[!EnableMeasure MeasureCheckNetwork]
UpdateDivider=-1

[MeasureCheckNetwork]
Measure=Plugin
Plugin=SysInfo
SysInfoType=INTERNET_CONNECTIVITY
Disabled=1
IfCondition=MeasureCheckNetwork = 1
IfTrueAction=[!Refresh *]

[MeterDummy]
Meter=String
What this will do is:

1) Start with the [MeasureCheckNetwork] measure disabled.
2) Use the internal Counter value in [MeasureOnLoad] to enable the network testing measure. The Counter value is incremented on every Update in a skin in Rainmeter, but is NOT reset on a skin refresh. Since we are looking for it to be exactly "1", it will only ever be "1" one time, when the skin is first loaded.
3) Test and keep testing every 100 milliseconds for Internet connectivity using [MeasureCheckNetwork]
4) When [MeasureCheckNetwork] becomes "1" (Internet connectivity detected), refresh all skins. Since this skin is refreshed along with all others, it will again start with [MeasureCheckNetwork] "disabled", but since the Counter value in [MeasureOnLoad] will be greater than "1" (it will be and stay "2" in fact) the [MeasureCheckNetwork] measure will remain "disabled" and there is no risk of some endless "refresh loop".

So just create and load this skin. It will be invisible, will take zero resources, and will only take action once, when Rainmeter is first started, which is generally going to be when your system is first rebooted. It will wait for the Internet to be detected, and as soon as it is, refresh all skins so they can properly update if they are using WebParser or other network dependent functions. Then this skin will just go to sleep until the next time you reboot.

So your skins will still load with no values, but the instant that there is Internet connectivity, they will automatically fix themselves.

Note that this is designed to work if you shutdown, (hybrid or full) or restart your computer. It won't work if you are just sleeping or hibernating your computer.
You do not have the required permissions to view the files attached to this post.
User avatar
goeway
Posts: 21
Joined: March 20th, 2019, 8:50 pm

Re: Rainmeter starts before Network

Post by goeway »

I have a doubt that it won't work when the network is disconnected and connected again. (Translated by Google)