It is currently March 28th, 2024, 8:06 am

Hourly auto calendar skin change?

Get help with creating, editing & fixing problems with skins
Domestican
Posts: 16
Joined: March 16th, 2018, 1:31 pm

Hourly auto calendar skin change?

Post by Domestican »

I have a load of calendar skins and would like to know if i can set it up so that that they will auto change every hour through this collection? if so how do i do it? if i saved them in different layouts could i switch the layout each hour? thanks
Dom ;)
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Hourly auto calendar skin change?

Post by balala »

Domestican wrote:if i saved them in different layouts could i switch the layout each hour?
First attempt:

Code: Select all

[MeasureHour]
Measure=Time
Format=%H
IfCondition=(#CURRENTSECTION#%2=0)
IfTrueAction=[!LoadLayout "FirstLayout"]
IfFalseAction=[!LoadLayout "SecondLayout"]
If the hour is an even number (divisible with 2), the IfTrueAction loads the FirstLayout. If on the other hand, it is an odd number, the IfFalseAction will load the SecondLayout. Obviously the necessary condition this to happen is to save previously the two layouts.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Hourly auto calendar skin change?

Post by jsmorley »

You are going to have to have a skin, one that is active in ALL the Layouts you define, that changes the Layout when a Time measure is at the top of the hour.

You are going to have to have it select a "random" Layout from a list you create, as there is no easy way to have it keep track of "where it is" in any list due to all skins being refreshed. There might be a way using !WriteKeyValue to have the last Layout it loaded be "persistent", but let's keep it as simple as we can for now.

So something like this:

Code: Select all

[Rainmeter]
Update=1000

[Variables]
Layout1=myLayout1
Layout2=myLayout2
Layout3=myLayout3
Layout4=myLayout4
Layout5=myLayout5
Layout6=myLayout6
Layout7=myLayout7

[MeasureRandom]
Measure=Calc
Formula=Random
LowBound=1
HighBound=7
UpdateDivider=-1

[MeasureMinute]
Measure=Time
Format=%#M
[MeasureSecond]
Measure=Time
Format=%#S

[MeasureOnHour]
Measure=Calc
IfCondition=(MeasureMinute = 0) && (MeasureSecond = 0)
IfTrueAction=[!LoadLayout "[#Layout[&MeasureRandom]]"]
DynamicVariables=1

[MeterDummy]
Meter=String
This depends on the variables being named with a number value to use with the random number, but the Layouts can be named anything you want. Note while testing that if a named Layout doesn't exist, the !LoadLayout bang will just silently fail.

A new random number will be generated each time a Layout is loaded, but I do caution that UniqueRandom won't work in this scenario, so it is possible that the same Layout could be loaded twice, much as throwing a pair of dice can be snake-eyes twice in a row. The fewer Layouts you have in the list, the statistically more likely this will be.

Solving that would be a bit more complicated, as you would have to use !WriteKeyValue to write the "number" of the Layout variable you are about to load to a variable in the actual skin file, and then use that value in a Calc measure that adds + 1 to it before loading the next one, and resets to "1" when the maximum number is reached. That would create a "loop" through the numbered Layouts, but then it wouldn't be able to be "random", just always in the same order.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Hourly auto calendar skin change?

Post by jsmorley »

balala wrote:First attempt:

Code: Select all

[MeasureHour]
Measure=Time
Format=%H
IfCondition=(#CURRENTSECTION#%2=0)
IfTrueAction=[!LoadLayout "FirstLayout"]
IfFalseAction=[!LoadLayout "SecondLayout"]
If the hour is an even number (divisible with 2), the IfTrueAction loads the FirstLayout. If on the other hand, it is an odd number, the IfFalseAction will load the SecondLayout. Obviously the necessary condition this to happen is to save previously the two layouts.
I caution that that test will always be either true or false, and be in effect in an endless loop. Since loading a Layout will reload the skin, the action will fire repeatedly, as fast as it can, which is really fast... This will be fatal to Rainmeter.

He wants to load a Layout "on the hour", (*:00:00) not any "particular" hour.
Domestican
Posts: 16
Joined: March 16th, 2018, 1:31 pm

Re: Hourly auto calendar skin change?

Post by Domestican »

thanks jsmorley - would this be done in the saved layouts edit file? or an ini file in each skin?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Hourly auto calendar skin change?

Post by jsmorley »

Domestican wrote:would this be done in the saved layouts edit file? or an ini file in each skin?
You would need to create the above as a skin, call it say "LayoutLoader.ini".

Then make sure that skin is loaded and active in all the Layout files you save. You can actually load each of them one at a time, load that skin, and re-save them, or just edit them and add the entire [LayoutLoader] section to each. If you have a lot, the second approach might be less hassle, as you have to also be sure that you do the first approach while there is no risk that the "top of the hour" hits, or it will interrupt things and be a mess.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Hourly auto calendar skin change?

Post by jsmorley »

The skin will just run invisibly and silently in the background, waiting for the top of the hour to hit. It will take virtually no resources, as the only work it will do is to track the minutes and seconds.
Domestican
Posts: 16
Joined: March 16th, 2018, 1:31 pm

Re: Hourly auto calendar skin change?

Post by Domestican »

thanks again will see if it works soon, if not i'll ask again ;)
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Hourly auto calendar skin change?

Post by jsmorley »

Note that personally, I wouldn't use this approach. it's too complicated and constraining for my tastes, as no matter what you are doing or working on in Rainmeter, this thing is going to pull the rug out from under you any time the clock strikes the hour. It will also reload, and thus visibly refresh, every other skin you have loaded, not just the calendar skin. This would quickly become annoying to me.

I'd be tempted instead to create a list of the calendar skins, and at the top of EACH of them add this functionality, but instead of using !LoadLayout, use !ActivateConfig to load a particular calendar skin, rather than an entire Layout. Much less disruptive in my view.

So your variables might look like:

[Variables]
Cal1=[!ActivateConfig "MyFirstCalendar" "MyFirstCalendar.ini"]
Cal2=[!ActivateConfig "MySecondCalendar" "MySecondCalendar.ini"]

And the IfTrueAction might look like:

IfTrueAction=[!DeactivateConfig "#CURRENTCONFIG#][#Cal[&MeasureRandom]]

You would need the [Variables], the Time measure(s), the [MeasureRandom] measure, and the Calc measure with the IfCondition somewhere in EACH of the calendar skins you want to use in this approach. That's a hassle to set up I guess, but the upside is that on the hour, you just get a different calendar skin loaded, and not the nuclear option of loading an entire Layout.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Hourly auto calendar skin change?

Post by jsmorley »

Domestican wrote:thanks again will see if it works soon, if not i'll ask again ;)
Glad to help. You can test it by setting the value of the Format option on [MeasureMinutes] to Format=0. Then it will be executed at the top of each minute, rather than the top of each hour.
Post Reply