It is currently March 28th, 2024, 4:31 pm

"scheduled" switch between skins

Get help with creating, editing & fixing problems with skins
Post Reply
User avatar
FuzzyLizard530
Posts: 75
Joined: August 5th, 2014, 2:09 am

"scheduled" switch between skins

Post by FuzzyLizard530 »

I'll keep it as simple as possible.

I have two skins that are in the same folder [00-POSI/Screen2/]. I'll call them "Gallery.ini" and "Time.ini".

I need "Time" displayed between 2-4:30pm, and gallery displayed the rest of the time. I've been away too long, and am struggling to figure out what/how to put into each skin to make one switch to the other automatically. I'd also like a "control panel" with a button to switch to either one.

Bonus "points" if all the code can be put into one skin...

What do we got out there?
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: "scheduled" switch between skins

Post by balala »

FuzzyLizard530 wrote: October 18th, 2020, 7:01 pm I have two skins that are in the same folder [00-POSI/Screen2/]. I'll call them "Gallery.ini" and "Time.ini".

I need "Time" displayed between 2-4:30pm, and gallery displayed the rest of the time. I've been away too long, and am struggling to figure out what/how to put into each skin to make one switch to the other automatically.
You need a Time measure, with a proper Format option. In order to keep the code as simple as possible, the Format has to return the time as a decimal number. An IfCondition is used to check if the time is in the limits or not and the IfTrueAction / IfFalseAction loads the appropriate skin.
Two variables are also needed, to store the limits of the period:

Code: Select all

[Variables]
Start=14.00
End=16.30

[MeasureTime]
Measure=TIME
Format=%#H.%M
IfCondition=((#CURRENTSECTION#>=#Start#)&&(#CURRENTSECTION#<=#End#))
IfTrueAction=[!ActivateConfig "00-POSI\Screen2" "Time.ini"]
IfFalseAction=[!ActivateConfig "00-POSI\Screen2" "Gallery.ini"]
Note that the Start and End variables has to be in 24 hours format (not the 12 hour format!) and you have to use decimal point between the hour and minut, because these variables are treated as decimal numbers, not as time.
FuzzyLizard530 wrote: October 18th, 2020, 7:01 pm I'd also like a "control panel" with a button to switch to either one.
This is possible for sure, however first check the above code and let's see if it does properly working. Adding the button is not a too hard thing and we'll add it later, everything is alright. Is it?
User avatar
FuzzyLizard530
Posts: 75
Joined: August 5th, 2014, 2:09 am

Re: "scheduled" switch between skins

Post by FuzzyLizard530 »

So far, it SEEMS like it works... I can get my Basic control panel to load at least...
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: "scheduled" switch between skins

Post by balala »

FuzzyLizard530 wrote: October 18th, 2020, 7:38 pm So far, it SEEMS like it works... I can get my Basic control panel to load at least...
Basic control panel being any of the Time.ini or Gallery.ini skins?
Test the skin for a while and if you find it ok, will add the button to the control panel (although I have to admit I don't exactly see what are you talking about / want, but this probably will be much clearer later).
User avatar
FuzzyLizard530
Posts: 75
Joined: August 5th, 2014, 2:09 am

Re: "scheduled" switch between skins

Post by FuzzyLizard530 »

balala wrote: October 18th, 2020, 7:45 pm Basic control panel being any of the Time.ini or Gallery.ini skins?
I have a third skin "refresh.ini" that I set up to manage the other two... Sorry for the confusion. LOL! Code below...

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1

[Metadata]
Name=ExampleMeterButton
Author=The Rainmeter Team
Information=Example of the Button meter
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Version=1.0

[Variables]
BarWidth=96
BarHeight=32
Start=13.55
End=16.30

[DateDayTime]
Measure=TIME
Format=%#H.%M
IfCondition=((#CURRENTSECTION#>=#Start#)&&(#CURRENTSECTION#<=#End#))
IfTrueAction=[!ActivateConfig "00-POSI\Screen2" "Time.ini"]
IfFalseAction=[!ActivateConfig "00-POSI\Screen2" "Gallery.ini"]

[MeterImageLogo]
Meter=Bar
BarColor=128,128,128
W=#BarWidth#
H=#BarHeight#
LeftMouseUpAction=[!ActivateConfig "00-POSI\Screen2" "Logo.ini"]

[MeterImageGall]
Meter=Bar
BarColor=128,128,128
Y=34
W=#BarWidth#
H=#BarHeight#
LeftMouseUpAction=[!ActivateConfig "00-POSI\Screen2" "Gallery.ini"]
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: "scheduled" switch between skins

Post by balala »

FuzzyLizard530 wrote: October 18th, 2020, 8:13 pm I have a third skin "refresh.ini" that I set up to manage the other two... Sorry for the confusion. LOL! Code below...
Such in a case I'd use another approach: recommend to add a variable and load the appropriate skin based on the value of that variable. Let's name this variable Skin:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1

[Metadata]
Name=ExampleMeterButton
Author=The Rainmeter Team
Information=Example of the Button meter
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Version=1.0

[Variables]
BarWidth=96
BarHeight=32
Start=13.55
End=16.30
Skin=0

[DateDayTime]
Measure=TIME
Format=%#H.%M
IfCondition=((#CURRENTSECTION#>=#Start#)&&(#CURRENTSECTION#<=#End#))
IfTrueAction=[!SetVariable Skin "1"][!UpdateMeasure "MeasureSkin"]
IfFalseAction=[!SetVariable Skin "0"][!UpdateMeasure "MeasureSkin"]

[MeasureSkin]
Measure=Calc
Formula=#Skin#
Ifcondition=(#CURRENTSECTION#>=1)
IfTrueAction=[!ActivateConfig "00-POSI\Screen2" "Logo.ini"]
IfFalseAction=[!ActivateConfig "00-POSI\Screen2" "Gallery.ini"]
DynamicVariables=1

[MeterImageLogo]
Meter=Bar
BarColor=128,128,128
W=#BarWidth#
H=#BarHeight#
LeftMouseUpAction=[!SetVariable Skin "1"][!UpdateMeasure "MeasureSkin"]

[MeterImageGall]
Meter=Bar
BarColor=128,128,128
Y=34
W=#BarWidth#
H=#BarHeight#
LeftMouseUpAction=[!SetVariable Skin "0"][!UpdateMeasure "MeasureSkin"]
See that the [MeterImageLogo] and the [MeterImageGall] meters, as well as the [DateDayTime] measure are setting the different values for the Skin variable. The [MeasureSkin] loads the appropriate skin, based on the value of the variable.
User avatar
FuzzyLizard530
Posts: 75
Joined: August 5th, 2014, 2:09 am

Re: "scheduled" switch between skins

Post by FuzzyLizard530 »

so far this skin is working marvellously! I'd like to expand the schedule a bit so that I could add a couple more slots to do more with this, and possibly run some batch files and other command-line goodness. thoughts?
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: "scheduled" switch between skins

Post by balala »

FuzzyLizard530 wrote: February 7th, 2021, 5:08 pm I'd like to expand the schedule a bit so that I could add a couple more slots to do more with this, and possibly run some batch files and other command-line goodness. thoughts?
The basic idea is to have a Time measure, which retuns the time as a decimal number (using a decimal dot between the hour and minutes, instead of colon). This way the number can be easily used into IfCondition options, to get the appropriate operation when the time achieves the proper value.
See the code I posted last time:

Code: Select all

[DateDayTime]
Measure=TIME
Format=%#H.%M
IfCondition=((#CURRENTSECTION#>=#Start#)&&(#CURRENTSECTION#<=#End#))
IfTrueAction=[!SetVariable Skin "1"][!UpdateMeasure "MeasureSkin"]
IfFalseAction=[!SetVariable Skin "0"][!UpdateMeasure "MeasureSkin"]

[MeasureSkin]
Measure=Calc
Formula=#Skin#
Ifcondition=(#CURRENTSECTION#>=1)
IfTrueAction=[!ActivateConfig "00-POSI\Screen2" "Logo.ini"]
IfFalseAction=[!ActivateConfig "00-POSI\Screen2" "Gallery.ini"]
DynamicVariables=1
The [DateDayTime] Time measure has the following format: Format=%#H.%M. As you can see the format corresponds to a decimal number: the integer part of this number is the hour, while its decimal part is the minute. Note that as said, you have to use here the 24-hour format, in order to have a difference between the AM and PM hours. Right now for me for instance, the measure returns 19.27 (here it's 7:27 PM). In the IfCondition option of the same [DateDayTime] measure I checked if the value returned by the measure (used here as #CURRENTSECTION#, not as DateDayTime - I offten use this trick to have an easily copaible expression, which can be pasted into another measure, without rewriting the name) is into the #Start# - #End# range. If it is, the first bang of the IfTrueAction option sets the Skin variable to 1, otherwise the IfFalseAction sets it to 0. The [MeasureSkin] measure acts according to the previously set value: it loads one or the other skin, depending on the value set to the Skin variable.
Extending this is pretty simple: remove the IfFalseAction option of the [DateDayTime] measure and add furhter IfConditions / IfTrueActions, to cover the whole range from 0.00 to 23.59. For instance:

Code: Select all

[DateDayTime]
Measure=TIME
Format=%#H.%M
IfCondition=(#CURRENTSECTION#<=6)
IfTrueAction=[!SetVariable Skin "1"][!UpdateMeasure "MeasureSkin"]
IfCondition2=((#CURRENTSECTION#>6)&&(#CURRENTSECTION#<=18))
IfTrueAction2=[!SetVariable Skin "2"][!UpdateMeasure "MeasureSkin"]
IfCondition3=(#CURRENTSECTION#>18)
IfTrueAction3=[!SetVariable Skin "3"][!UpdateMeasure "MeasureSkin"]

[MeasureSkin]
Measure=Calc
Formula=#Skin#
IfCondition=(#CURRENTSECTION#=1)
IfTrueAction=[!ActivateConfig "00-POSI\Screen2" "Logo.ini"]
IfCondition2=(#CURRENTSECTION#=2)
IfTrueAction2=[!ActivateConfig "00-POSI\Screen2" "Gallery.ini"]
IfCondition3=(#CURRENTSECTION#=3)
IfTrueAction3=[!ActivateConfig "00-POSI\Screen2" "ThirdSkin.ini"]
In this case the IfConditions of the [DateDayTime] measure checks the value returned by the measure. If the time is before 6 AM (is below 6 - which corresponds to 6 AM in 24-hour format), the IfTrueAction sets the value of the Skin variable to 1. Accordingly the [MeasureSkin] loads the Logo.ini skin. If the time is between 6 AM (6) and 6 PM (18), IfTrueAction2 is executed and accordingly [MeasureSkin] loads the Gallery.ini skin. Finally after 6 PM (18), on the same procedure, ThirdSkin.ini is loaded.
The [MeasureSkin] measure is not absolutely needed. If it seems simpler for you, you can add the appropriate bangs which have to be executed, directly to the IfTrueAction options of the [DateDayTime] measure.
Please let me know if you have any question.
Post Reply