It is currently April 19th, 2024, 8:34 pm

!SetWallpaper doesn't seem to be doing anything.

Get help with creating, editing & fixing problems with skins
Cougar Draven
Posts: 8
Joined: May 28th, 2017, 9:15 pm

!SetWallpaper doesn't seem to be doing anything.

Post by Cougar Draven »

Okay, hi, everyone. I'm still sort of new to the whole Rainmeter thing (in that I've figured out how to pull relevant bits from other skins to see how they work and create a few of my own), and I've run into a problem.

I want to have my wallpaper to be changed to one of four images based on the time of day. This is not a new problem here, but I'm running into two problems. The second, which is less important, is I'd like to know how to make the skin check the time every, say, five minutes, to make sure it's still within the right time to have the current wallpaper up. The first, and more important, is that as far as I can tell it's just not doing anything at all. I've changed the time several times, and I'm currently using a wallpaper that isn't even one of the four just so I'll know when it does anything, and to date, no change. I'll throw my in-progress code below, and any help is appreciated. There's probably quite a bit of superfluous extra in there, but I can't figure out what's going wrong.

Code: Select all

[Rainmeter]
Update=1000

[mTime]
Measure=Time
Format=%#H%M
DynamicVariables=1

[mCalc]
Measure=Calc
Formula=(([mTime]>0500)&&([mTime]<1200)?1:([mTime]>1200)&&([mTime]<1600)?2:([mTime]>1600)&&([mTime]<2100)?3:([mTime]>2100)&&([mTime]<0500)?4:0)
IfCondition=1
IfTrueAction=[!SetWallpaper "#@#tod 1.jpg" Fill][!Update]
IfCondition2=2
IfTrueAction2=[!SetWallpaper "#@#tod 2.jpg" Fill][!Update]
IfCondition3=3
IfTrueAction3=[!SetWallpaper "#@#tod 3.jpg" Fill][!Update]
IfCondition4=4
IfTrueAction4=[!SetWallpaper "#@#tod 4.jpg" Fill][!Update]
DynamicVariables=1

[mDummy]
Meter=String
Edit: I'm trying some other things with this, still haven't gotten it to work. I tried replacing the update bang with an UpdateMeter and putting the conditions in the dummy meter. Still hasn't worked yet, but I can give one piece of advice: don't try to replace-all using a bang and Notepad++ set to regular expressions. It isn't pretty.

Edit 2: Okay, so it's working now. I understand how this is working (see added code snippet at bottom), but I'd really like to not have to change it every single hour, so if there's a way to get my first code to work, I'd like to know. Thanks again.

Code: Select all

[Rainmeter]
Update=30000
OnUpdateAction=!SetWallpaper "#@#[mHour].jpg"

[mHour]
Measure=Time
Format=%#H

[mDummy]
Meter=String
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: !SetWallpaper doesn't seem to be doing anything.

Post by mak_kawa »

I think...

Code: Select all

IfCondition=(mCalc=1)
IfTrueAction=[!SetWallpaper "#@#tod 1.jpg" Fill][!Update]
IfCondition2=(mCalc=2)
IfTrueAction2=[!SetWallpaper "#@#tod 2.jpg" Fill][!Update]
IfCondition3=(mCalc=3)
IfTrueAction3=[!SetWallpaper "#@#tod 3.jpg" Fill][!Update]
IfCondition4=(mCalc=4)
IfTrueAction4=[!SetWallpaper "#@#tod 4.jpg" Fill][!Update]
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: !SetWallpaper doesn't seem to be doing anything.

Post by mak_kawa »

My worry... Is the calc formula you wrote OK?
And in your code, wallpaper may be changed at every update cycle (1000 ms), isn't it?

Here is my solution. But I didn't try actually this code. Sorry if this doesn't work.

Code: Select all

[Rainmeter]
Update=1000

[Variables]
FirstLoad=1

[mTime]
Measure=Time
Format=%#H

[mCalc]
Measure=Calc
Formula=([mTime]>5)&&([mTime]<12)?1:(([mTime]>12)&&([mTime]<16)?2:(([mTime]>16)&&([mTime]<21)?3:(([mTime]>21)&&([mTime]<5)?4:0)))

IfCondition=(#FirstLoad#=1)
IfTrueAction=[!SetWallpaper "#@#tod [mCalc].jpg" Fill][!SetVariable FirstLoad 0][!Update]

OnChangeAction=[!SetWallpaper "#@#tod [mCalc].jpg" Fill][!Update]
DynamicVariables=1

[mDummy]
Meter=String
User avatar
balala
Rainmeter Sage
Posts: 16147
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: !SetWallpaper doesn't seem to be doing anything.

Post by balala »

As I see, a few things should be clarified. So, let's do it:
  • As mak_kawa said in his first reply, an IfCondition=1 (or any value) option should usually be avoided. Although Rainmeter treats the value 1 as true and 0 as false, it's better to get used to use in the IfCondition a "real" condition, like: IfCondition=(mCalc=1), which indeed can be true or false, depending on the value returned by the measure.
  • On the other hand, for both of you Cougar Draven and mak_kawa, the ([mTime]>2100)&&([mTime]<0500) part of the formula is never true, because [mTime] can't be in the same time greater then 2100 AND smaller then 500. This is a very common mistake and you have to be careful, because there are two possibilities: you either can replace this with ([mTime]>2100)||([mTime]<0500) (will be met after 21:00 and before 5:00), or can replace the whole ([mTime]>2100)&&([mTime]<0500)?4:0 expression, with 4. That because [mTime] represents in fact the time, and this time can't go outside of the 0 - 2400 (0:00 - 23:59) interval. 0 will never be returned by the measure:
    1.

    Code: Select all

    [mCalc]
    ...
    Formula=(([mTime]>0500)&&([mTime]<1200)?1:([mTime]>1200)&&([mTime]<1600)?2:([mTime]>1600)&&([mTime]<2100)?3:4)
    2.

    Code: Select all

    [mCalc]
    ...
    Formula=(([mTime]>0500)&&([mTime]<1200)?1:([mTime]>1200)&&([mTime]<1600)?2:([mTime]>1600)&&([mTime]<2100)?3:([mTime]>2100)||([mTime]<0500)?4:0)
  • Setting dynamic variables on the [mTime] measure, is completely useless. There is no reason for a such option.
  • The [!Update] bangs on the end of each IfTrueAction option of the [mCalc], is again useless. You don't have to update the whole skin, when you set a new wallpaper, especially that setting it, doesn't affect the skin, but the OS instead. Simply doesn't worth to update the skin.
  • Cougar Draven wrote:and putting the conditions in the dummy meter. Still hasn't worked yet,
    Meters don't accept IfConditions. These options belong to measures, they can be used only on measures.
Cougar Draven
Posts: 8
Joined: May 28th, 2017, 9:15 pm

Re: !SetWallpaper doesn't seem to be doing anything.

Post by Cougar Draven »

balala wrote:On the other hand, for both of you Cougar Draven and mak_kawa, the ([mTime]>2100)&&([mTime]<0500) part of the formula is never true, because [mTime] can't be in the same time greater then 2100 AND smaller then 500. This is a very common mistake and you have to be careful, because there are two possibilities: you either can replace this with ([mTime]>2100)||([mTime]<0500) (will be met after 21:00 and before 5:00), or can replace the whole ([mTime]>2100)&&([mTime]<0500)?4:0 expression, with 4. That because [mTime] represents in fact the time, and this time can't go outside of the 0 - 2400 (0:00 - 23:59) interval. 0 will never be returned by the measure:
1.

Code: Select all

[mCalc]
...
Formula=(([mTime]>0500)&&([mTime]<1200)?1:([mTime]>1200)&&([mTime]<1600)?2:([mTime]>1600)&&([mTime]<2100)?3:4)
2.

Code: Select all

[mCalc]
...
Formula=(([mTime]>0500)&&([mTime]<1200)?1:([mTime]>1200)&&([mTime]<1600)?2:([mTime]>1600)&&([mTime]<2100)?3:([mTime]>2100)||([mTime]<0500)?4:0)
In retrospect, I feel silly for not putting that together. Boolean logic is pretty simple.
balala wrote:
  • Setting dynamic variables on the [mTime] measure, is completely useless. There is no reason for a such option.
  • The [!Update] bangs on the end of each IfTrueAction option of the [mCalc], is again useless. You don't have to update the whole skin, when you set a new wallpaper, especially that setting it, doesn't affect the skin, but the OS instead. Simply doesn't worth to update the skin.
I had figured that, but I also was guessing that it didn't really hurt anything either, and I'm a "better safe than sorry" kind of person. I'll remove those in the final version of this.
User avatar
balala
Rainmeter Sage
Posts: 16147
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: !SetWallpaper doesn't seem to be doing anything.

Post by balala »

Cougar Draven wrote:I had figured that, but I also was guessing that it didn't really hurt anything either, and I'm a "better safe than sorry" kind of person. I'll remove those in the final version of this.
No, it really doesn't, however updating the skin for nothing, at least in my opinion, simply doesn't worth. Along with the update a complete redrawn of the skin is done and that could be a bit more expensive.