It is currently April 27th, 2024, 10:59 am

Change layout based on time not working!

Get help with creating, editing & fixing problems with skins
ClaymoreRoomba
Posts: 2
Joined: March 20th, 2024, 10:33 pm

Change layout based on time not working!

Post by ClaymoreRoomba »

I have added the following code to a skin which is just a background, however, despite mHour being the correct value (I checked through "open log > skins"), the layout does not get changed. Any ideas on how to fix this?

Code: Select all

[Rainmeter]

[Background]
Meter=Image
ImageName=firewatch-day.jpg
W=2048
H=1280

[mHour]
Measure=Time
Format=%H
UpdateDivider=10
IfCondition=(mHour >=18 || mHour <6)
IfTrueCondition=[!LoadLayout "firewatchEvening"]
[dummy]
Meter=String
I also have another background skin which is displayed when the layout changes which code is nearly identical:

Code: Select all

[Rainmeter]

[Background]
Meter=Image
ImageName=firewatch-evening.jpg
W=2048
H=1280

[mHour]
Measure=Time
Format=%H
UpdateDivider=10
IfCondition=(mHour >=6 && mHour <18)
IfTrueCondition=[!LoadLayout "firewatchDay"]
[dummy]
Meter=String
Any help would be greatly appreciated :)
You do not have the required permissions to view the files attached to this post.
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Change layout based on time not working!

Post by Yincognito »

ClaymoreRoomba wrote: March 20th, 2024, 10:44 pm I have added the following code to a skin which is just a background, however, despite mHour being the correct value (I checked through "open log > skins"), the layout does not get changed. Any ideas on how to fix this?

Code: Select all

[Rainmeter]

[Background]
Meter=Image
ImageName=firewatch-day.jpg
W=2048
H=1280

[mHour]
Measure=Time
Format=%H
UpdateDivider=10
IfCondition=(mHour >=18 || mHour <6)
IfTrueCondition=[!LoadLayout "firewatchEvening"]
[dummy]
Meter=String
I also have another background skin which is displayed when the layout changes which code is nearly identical:

Code: Select all

[Rainmeter]

[Background]
Meter=Image
ImageName=firewatch-evening.jpg
W=2048
H=1280

[mHour]
Measure=Time
Format=%H
UpdateDivider=10
IfCondition=(mHour >=6 && mHour <18)
IfTrueCondition=[!LoadLayout "firewatchDay"]
[dummy]
Meter=String
Any help would be greatly appreciated :)
Actually, none of your skins "work", because it's not IfTrueCondition, but IfTrueAction:
https://docs.rainmeter.net/manual/measures/general-options/ifconditions/

Also, if your layouts are simply made of the opposite skin, you could just change the value of the ImageName option from your Image meter accordingly, in a single skin, via !SetOption, !UpdateMeter and !Redraw in the IfTrueAction / IfTrueAction2 of some corresponding IfCondition / IfCondition2, roughly similar to the example code at the end of the page linked above.

https://docs.rainmeter.net/manual/bangs/#UpdateMeter
https://docs.rainmeter.net/manual/bangs/#Redraw
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
ClaymoreRoomba
Posts: 2
Joined: March 20th, 2024, 10:33 pm

Re: Change layout based on time not working!

Post by ClaymoreRoomba »

Thank you, I have changed the lines from IfTrueCondition to IfTrueAction; however, there still seems to be an issue, as the layouts don't seem to be swapping from day to evening. Even swapping to firewatchEvening manually just instantly reloads the firewatchDay layout. I therefore believe there must be a logic error in the firewatch-evening skin that somehow always returns true, however I cannot for the life of me understand what it is. Any extra help is much appreciated! :)
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Change layout based on time not working!

Post by Yincognito »

ClaymoreRoomba wrote: March 21st, 2024, 5:18 pm Thank you, I have changed the lines from IfTrueCondition to IfTrueAction; however, there still seems to be an issue, as the layouts don't seem to be swapping from day to evening. Even swapping to firewatchEvening manually just instantly reloads the firewatchDay layout. I therefore believe there must be a logic error in the firewatch-evening skin that somehow always returns true, however I cannot for the life of me understand what it is. Any extra help is much appreciated! :)
Well, there is a syntax particularity, in that the comparisons on either side of logical AND && and OR || operators must be enclosed between round brackets (like below), but that shouldn't interfere too much with the system, especially when switching from a layout to another manually...

firewatchDay.ini:

Code: Select all

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

[mHour]
Measure=Time
Format=%H
UpdateDivider=10
IfCondition=(mHour >= 18) || (mHour < 6)
IfTrueAction=[!LoadLayout "firewatchEvening"]

[Background]
Meter=Image
ImageName=firewatch-day.jpg
W=1920
H=1050
LeftMouseUpAction=[!LoadLayout "firewatchEvening"]
firewatchEvening.ini:

Code: Select all

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

[mHour]
Measure=Time
Format=%H
UpdateDivider=10
IfCondition=(mHour >= 6) && (mHour < 18)
IfTrueAction=[!LoadLayout "firewatchDay"]

[Background]
Meter=Image
ImageName=firewatch-evening.jpg
W=1920
H=1050
LeftMouseUpAction=[!LoadLayout "firewatchDay"]
The above works fine for me (I've changed the resolution based on the size of my laptop screen, feel free to adjust it back). It's true that at one point I had a similar issue to yours, but it was because I didn't properly save the layouts. To be more specific, the code in the skins is such that it will switch to the corresponding layout based on time, so you must make sure that the layout you save is the one for the desired part of day (i.e. that what you save is not the effect of the switching). To do that easier, I recommend commenting out (precede the lines with a ; symbol) the two IfCondition lines in each skin and refresh them before saving the layouts, so that the automatic switch doesn't cause you to save a layout with the "wrong" skin being active. Afterwards, you can uncomment those parts easily, by removing the ; at the start of the said lines.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16176
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change layout based on time not working!

Post by balala »

EDIT: Sorry, Yincognito beat me, as usually...
ClaymoreRoomba wrote: March 21st, 2024, 5:18 pm however, there still seems to be an issue, as the layouts don't seem to be swapping from day to evening.
There is, and additionally there is something missing as well.
The error logic is that if here are more than one single logical expression in the IfCondition option, you have to include each of those expressions into parantheses. This way, for instance: IfCondition=((mHour>=6)&&(mHour<18)). If you do this, there still is a thing you have to take into account. This is not an error, but you have to know that since there is only an IfTrueAction, this option is executed when the time reaches the appropriate value (is between 6 and 18 every day). When the time is outside of these boundaries, nothing is executed (there not being an IfFalseAction option). If the skin is activated when the time reaches the "upper" limit (18) since according to the IfTrueAction the firewatchDay layout has been loaded, it is kept even after 18. Nothing loads the firewatchEvening layout.
To load this layout outside of the specified interval, add an IfFalseAction=[!LoadLayout "firewatchEvening"] option to the [mHour] measure. This way the firewatchDay layout is loaded in the 6 - 18 interval, while firewatchEvening outside of this interval.
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Change layout based on time not working!

Post by Yincognito »

balala wrote: March 21st, 2024, 6:43 pmIf you do this, there still is a thing you have to take into account. This is not an error, but you have to know that since there is only an IfTrueAction, this option is executed when the time reaches the appropriate value (is between 6 and 18 every day). When the time is outside of these boundaries, nothing is executed (there not being an IfFalseAction option). If the skin is activated when the time reaches the "upper" limit (18) since according to the IfTrueAction the firewatchDay layout has been loaded, it is kept even after 18. Nothing loads the firewatchEvening layout.
To load this layout outside of the specified interval, add an IfFalseAction=[!LoadLayout "firewatchEvening"] option to the [mHour] measure. This way the firewatchDay layout is loaded in the 6 - 18 interval, while firewatchEvening outside of this interval.
I'm guessing the OP imagined the skin in the "other" layout handling the "opposite" switching, but you're right about the moment of skin loading. :???:

Personally, like I said earlier, if it was just about changing a "wallpaper image" (and not necessarily about an arrangement of skins on the screen), like it seems to be, I would have either used a !SetOption on the ImageName option of [Background], or, even better, use the !SetWallpaper bang, either of them in a single skin. But that's just me, the OP knows best what he envisions. :confused:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth