It is currently April 26th, 2024, 9:37 am

Cant get skin to change wallpaper depending on time.

Get help with creating, editing & fixing problems with skins
dolyfin
Posts: 1
Joined: May 29th, 2020, 12:42 am

Cant get skin to change wallpaper depending on time.

Post by dolyfin »

I wanted to make a skin that uses !SetWallpaper to change wallpaper depending on the time. Somehow nothing works and I have no idea why. Images are located in the same folder as the .ini

Code: Select all

[Rainmeter]
Update=1

[Meter]
Meter=String

[MeasureHour]
Measure=Time
Format=%H
UpdateDivider=1
;SetDawn
IfCondition1=(MeasureHour = 07)
IfTrueAction1=[!SetWallpaper "Dawn.jpg"][!Redraw]
;SetDay
IfCondition2=(MeasureHour >= 08) && (MeasureHour < 17)
IfTrueAction2=[!SetWallpaper "Day.jpg" Fit][!Redraw]
;SetDusk
IfCondition3=(MeasureHour = 17)
IfTrueAction3=[!SetWallpaper "Dusk.jpg" Fit][!Redraw]
;SetNight
IfCondition4=(MeasureHour >= 18) && (MeasureHour <= 23) || (MeasureHour >= 00) && (MeasureHour < 07)
IfTrueAction4=[!SetWallpaper "Night.jpg" Fit][!Redraw]
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Cant get skin to change wallpaper depending on time.

Post by mak_kawa »

Hi dolyfin

Probably the reason is that you use invalid IfCondition expression. Modify "IfCondition1" and "IfTrueAction1" to "IfCondition" and "IfTrueAction"

Ps.: You should change Update=1 option to Update=1000 or some, because Update=1 means the measure is updated every 1 ms (0.001 second). This update specification is actually invalid. Rainmeter update cycle is 16 ms minimum.
User avatar
balala
Rainmeter Sage
Posts: 16172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Cant get skin to change wallpaper depending on time.

Post by balala »

mak_kawa wrote: May 29th, 2020, 1:08 am Probably the reason is that you use invalid IfCondition expression. Modify "IfCondition1" and "IfTrueAction1" to "IfCondition" and "IfTrueAction"
Not probably, but exactly. The first IfCondition and IfTrueAction (and accordingly the first IfFalseAction) options don't have number, only starting from the second ones. So, not IfCondition1 and IfTrueAction1, but IfCondition and IfTrueAction, then IfCondition2 and IfTrueAction2 and so on.
mak_kawa wrote: May 29th, 2020, 1:08 am Ps.: You should change Update=1 option to Update=1000 or some, because Update=1 means the measure is updated every 1 ms (0.001 second). This update specification is actually invalid. Rainmeter update cycle is 16 ms minimum.
No, practically Update=1 means nothing, because it is invalid (second paragraph here). The Update value is expressed into milliseconds, not seconds.
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: Cant get skin to change wallpaper depending on time.

Post by Mor3bane »

hi dolyfin

I liked your idea so I incorporated it into my skin.

The fall-through in this is a little more functional, just as an example...

Code: Select all


[MeasureHour]
Measure=Time
Format=%H
;SetDawn
IfCondition=(MeasureHour > 00) && (MeasureHour <= 06)
IfTrueAction=[!SetOption "NewFrameOne" "ImageTint" "250,112,0,255""][!Redraw]
;SetDay
IfCondition2=(MeasureHour >= 06) && (MeasureHour < 16)
IfTrueAction2=[!SetOption "NewFrameOne" "ImageTint" "242,212,165,255""][!Redraw]
;SetDusk
IfCondition3=(MeasureHour >= 16) && (MeasureHour < 18)
IfTrueAction3=[!SetOption "NewFrameOne" "ImageTint" "105,131,154,255""][!Redraw]
;SetNight
IfCondition4=(MeasureHour >= 18) && (MeasureHour <= 23)
IfTrueAction4=[!SetOption "NewFrameOne" "ImageTint" "45,45,90,255""][!Redraw]

My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Cant get skin to change wallpaper depending on time.

Post by mak_kawa »

Hi balala
In my country, people modestly says "probably" instead of "exactly", always... (just joking) :-)
User avatar
balala
Rainmeter Sage
Posts: 16172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Cant get skin to change wallpaper depending on time.

Post by balala »

Just as an additional side-note, it depends as well on where and how the value of the [MeasureHour] measure is used, but if it is not used elsewhere, I'd propose to modify the Format of the [MeasureHour] measure and the IfConditions as it follows:

Code: Select all

[MeasureHour]
Measure=Time
Format=%#H
UpdateDivider=1
;SetDawn
IfCondition=(MeasureHour = 7)
IfTrueAction=[!SetWallpaper "Dawn.jpg"][!Redraw]
;SetDay
IfCondition2=(MeasureHour >= 8) && (MeasureHour < 17)
IfTrueAction2=[!SetWallpaper "Day.jpg" Fit][!Redraw]
;SetDusk
IfCondition3=(MeasureHour = 17)
IfTrueAction3=[!SetWallpaper "Dusk.jpg" Fit][!Redraw]
;SetNight
IfCondition4=(MeasureHour >= 18) && (MeasureHour <= 23) || (MeasureHour >= 0) && (MeasureHour < 7)
IfTrueAction4=[!SetWallpaper "Night.jpg" Fit][!Redraw]
With the Format=%#H option, the leading zero is not used, so there is no need to use it nor in the IfConditions. Much cleverer, in my opinion.
Note that if the value of the [MeasureHour] measure is needed somewhere else in the code as well, you should ignore this.