It is currently October 1st, 2024, 10:49 pm

Changing color of clock skin based on time of day

Get help with creating, editing & fixing problems with skins
User avatar
sumduck
Posts: 9
Joined: August 3rd, 2021, 5:54 pm

Changing color of clock skin based on time of day

Post by sumduck »

Hello,

I've been trying to change the color of the clock skin (mond: https://www.deviantart.com/apexxx-sensei/art/Mond-762455575) I'm using according to my background, which is a Wallpaper Engine animated wallpaper, and changes depending on the time of day. Since it's a wallpaper run through Wallpaper Engine, and maybe also because it's animated, I don't think using Chameleon is an option in this case.

IfConditions however, are an actual possibility. I've been trying to get them to work, but integrating them into the already existing code of my clock skin has been confusing and frustrating at times for a noob like me, so I've come here as a last resort. I've attached the clock skin if you want to run it yourself, the zip file for the whole skin folder if you need that for some reason, and here's the clock skin's code if you're feeling lazy:

Code: Select all

[Rainmeter]
Update=1000
Author=Connect-R
BackgroundMode=2
SolidColor=0,0,0,1
DynamicWindowSize=1
AccurateText=1
MouseScrollUpAction=[!SetVariable Scale "(#Scale#+#ScrollMouseIncrement#)"][!WriteKeyValue Variables Scale "(#Scale#+#ScrollMouseIncrement#)"][!Refresh] 
MouseScrollDownAction=[!SetVariable Scale "(#Scale#-#ScrollMouseIncrement# < 0.5 ? 0.5 : #Scale#-#ScrollMouseIncrement#)"][!WriteKeyValue Variables Scale "(#Scale#-#ScrollMouseIncrement# < 0.5 ? 0.5 : #Scale#-#ScrollMouseIncrement#)"][!Refresh] 
LeftMouseDoubleClickAction=!ToggleConfig "Mond\Settings" "Settings.ini"

[Variables]
@include=#@#Variables.inc
@include2=#@#Language\Language.inc
Scale=1.16

;-------------------------------------------------------------
;-------------------------------------------------------------

[MeasureTime]
Measure=Time
Format="%#Format#:%M"

[MeasureAmPm]
Measure=Time
Format="%p"

[MeasureDay]
Measure=Time
Format=%A
Substitute=#Date#

[MeasureDate]
Measure=Time
Format=%d  %B,  %Y.
Substitute=#Date#

;-------------------------------------------------------------
;-------------------------------------------------------------

[Meter24hClock]
Meter=String
MeasureName=MeasureTime
StringAlign=Center
StringCase=Upper
FontFace=Quicksand
FontColor=#Color1#
FontSize=(14*#Scale#)
X=(340*#Scale#)
Y=(120*#Scale#)
Text="- %1 -"
AntiAlias=1
Hidden=#Hidden#

[Meter12hClock]
Meter=String
MeasureName=MeasureTime
MeasureName2=MeasureAmPm
StringAlign=Center
StringCase=Upper
FontFace=Quicksand
FontColor=#Color1#
FontSize=(14*#Scale#)
X=(0*#Scale#)r
Y=(0*#Scale#)r
Text="- %1 %2 -"
AntiAlias=1
Hidden=#Hidden2#

[MeterDay]
Meter=String
MeasureName=MeasureDay
StringAlign=Center
StringCase=Upper
FontFace=Anurati
FontColor=#Color1#
FontSize=(40*#Scale#)
X=(340*#Scale#)
Y=(0*#Scale#)
Text="%1"
InlineSetting=CharacterSpacing | (10*#Scale#) | (10*#Scale#)
AntiAlias=1
DynamicVariables=1

[MeterDate]
Meter=String
MeasureName=MeasureDate
StringAlign=Center
StringCase=Upper
FontFace=Quicksand
FontColor=#Color1#
FontSize=(14*#Scale#)
X=(340*#Scale#)
Y=(75*#Scale#)
Text="%1"
AntiAlias=1
Also, sorry if any formatting or anything is off, this is my first post and I'm completely new to all this.
You do not have the required permissions to view the files attached to this post.
User avatar
death.crafter
Rainmeter Sage
Posts: 1398
Joined: April 24th, 2021, 8:13 pm

Re: Changing color of clock skin based on time of day

Post by death.crafter »

sumduck wrote: August 3rd, 2021, 6:19 pm Hello,

I've been trying to change the color of the clock skin (mond: https://www.deviantart.com/apexxx-sensei/art/Mond-762455575) I'm using according to my background, which is a Wallpaper Engine animated wallpaper, and changes depending on the time of day. Since it's a wallpaper run through Wallpaper Engine, and maybe also because it's animated, I don't think using Chameleon is an option in this case.

IfConditions however, are an actual possibility. I've been trying to get them to work, but integrating them into the already existing code of my clock skin has been confusing and frustrating at times for a noob like me, so I've come here as a last resort. I've attached the clock skin if you want to run it yourself, the zip file for the whole skin folder if you need that for some reason, and here's the clock skin's code if you're feeling lazy:

Also, sorry if any formatting or anything is off, this is my first post and I'm completely new to all this.
What do you want exactly? If you were to use if conditions, where you would use them?
from the Realm of Death
User avatar
sumduck
Posts: 9
Joined: August 3rd, 2021, 5:54 pm

Re: Changing color of clock skin based on time of day

Post by sumduck »

In the clock skin code right? Like something that says if it's 5 pm, change the color to orange or something. Something like that I think.
User avatar
balala
Rainmeter Sage
Posts: 16616
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Changing color of clock skin based on time of day

Post by balala »

sumduck wrote: August 3rd, 2021, 6:19 pm Also, sorry if any formatting or anything is off, this is my first post and I'm completely new to all this.
Extending death.crafter's question, here are some general information, I wrote in meantime:
Changing a color based on time of day is a pretty easy task. You need only IfConditions. For instance you can add such option(s) to a newly added Time measure, which returns the hour. Something like this:

Code: Select all

[MeasureHour]
Measure=Time
Format=%#H
IfCondition=(MeasureHour<=6)
IfTrueAction=[!SetVariable MyColor "255,0,0"]
IfCondition2=((MeasureHour>6)&&(MeasureHour<=12))
IfTrueAction2=[!SetVariable MyColor "0,255,0"]
IfCondition3=((MeasureHour>12)&&(MeasureHour<=18))
IfTrueAction3=[!SetVariable MyColor "0,0,255"]
IfCondition4=(MeasureHour>18)
IfTrueAction4=[!SetVariable MyColor "255,240,0"]
As you probably can easily figure out, the above [MeasureHour] returns the hour of day, from 0 (in midnight) to 23 (before next midnight). The IfCondition - IfCondition4 options become true one after the other, in 6 hours steps and the appropriate IfTrueActions set accordingly the My Color variable from 255,0,0 (red), to 0,255,0 (green), then 0,0,255 (blue) and finally 255,240,0 (yellow). The color of this variable can be then used into another meter.
As you see, this is one solution. The possibilities are infinite. How and what would you like to set the color to?
User avatar
sumduck
Posts: 9
Joined: August 3rd, 2021, 5:54 pm

Re: Changing color of clock skin based on time of day

Post by sumduck »

So here's the colors I would like them to be set to:
0:00 - 8:00 White
8:00 - 16:00 Black
19:40 - 23:59 White

Also would I just put that code in the clock.ini file?
User avatar
balala
Rainmeter Sage
Posts: 16616
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Changing color of clock skin based on time of day

Post by balala »

sumduck wrote: August 3rd, 2021, 6:42 pm So here's the colors I would like them to be set to:
0:00 - 8:00 White
8:00 - 16:00 Black
19:40 - 23:59 White

Also would I just put that code in the clock.ini file?
Add my above [MeasureHour] measure to your code, modifying it slightly:

Code: Select all

[MeasureHour]
Measure=Time
Format=%#H.M
IfCondition=(MeasureHour<=8)
IfTrueAction=[!SetVariable MyColor "255,255,255"]
IfCondition2=((MeasureHour>8)&&(MeasureHour<=16))
IfTrueAction2=[!SetVariable MyColor "0,0,0"]
IfCondition3=(MeasureHour>19.40)
IfTrueAction3=[!SetVariable MyColor "255,255,255"]
In this code, I modified the Format option, to get a decimal number returned. The conditions are modified, however you didn't covered the 16:00 - 19:40 interval, which might be a typo, but it is?
Next question is how and where would you like to use the MyColor variable?
User avatar
sumduck
Posts: 9
Joined: August 3rd, 2021, 5:54 pm

Re: Changing color of clock skin based on time of day

Post by sumduck »

Oh sorry about that, 16:00 - 19:40 should be white.

I'm not sure where or how I would use that variable. I just want in to be so that the clock changes colors automatically based on time of day, so I assume just in the clock.ini file as well? I'm not really sure about this stuff.
User avatar
sumduck
Posts: 9
Joined: August 3rd, 2021, 5:54 pm

Re: Changing color of clock skin based on time of day

Post by sumduck »

OH wait do I just change the fontcolor= to the mycolor variable?

Also I tried to add to the thing you wrote myself.

Is this correct:

Code: Select all

[MeasureHour]
Measure=Time
Format=%#H.M
IfCondition=(MeasureHour<=8)
IfTrueAction=[!SetVariable MyColor "255,255,255"]
IfCondition2=((MeasureHour>8)&&(MeasureHour<=16))
IfTrueAction2=[!SetVariable MyColor "0,0,0"]
IfCondition3=((MeasureHour>16)&&(MeasureHour<=19.40))
IfTrueAction3=[!SetVariable MyColor "255,255,255"]
IfCondition4=(MeasureHour>19.40)
IfTrueAction4=[!SetVariable MyColor "255,255,255"]
User avatar
balala
Rainmeter Sage
Posts: 16616
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Changing color of clock skin based on time of day

Post by balala »

sumduck wrote: August 3rd, 2021, 6:59 pm OH wait do I just change the fontcolor= to the mycolor variable?

Also I tried to add to the thing you wrote myself.

Is this correct:

Code: Select all

[MeasureHour]
Measure=Time
Format=%#H.M
IfCondition=(MeasureHour<=8)
IfTrueAction=[!SetVariable MyColor "255,255,255"]
IfCondition2=((MeasureHour>8)&&(MeasureHour<=16))
IfTrueAction2=[!SetVariable MyColor "0,0,0"]
IfCondition3=((MeasureHour>16)&&(MeasureHour<=19.40))
IfTrueAction3=[!SetVariable MyColor "255,255,255"]
IfCondition4=(MeasureHour>19.40)
IfTrueAction4=[!SetVariable MyColor "255,255,255"]
Yep, change my MyColor variable, to Color1, which is used into the FontColor options, of all four String meters. However note the followings:
  • The changing won't have effect only on [MeterDay] meter, because when you change dynamically a variable, you have to have a DynamicVariables=1 option on all meters and measures where you want to use the variable. You have such a DynamicVariables=1 option only on [MeterDay], so add it to [Meter24hClock], [Meter12hClock] and[MeterDate] as well.
  • The variable is set to the same value (white - 255,255,255) on both the IfTrueAction3 and IfTrueAction4, so doesn't worth to have two distinct IfConditions for the 16:00 - 19:40 and 19:40 - 24:00 intervals. I suppose either in your code you did a typo again, one of those values should be 0,0,0, or you should unify the IfCondition3 and IfCondition4. So would you like to use the same color for those intervals?
User avatar
sumduck
Posts: 9
Joined: August 3rd, 2021, 5:54 pm

Re: Changing color of clock skin based on time of day

Post by sumduck »

No it wasnt a typo. I guess if its better to join them, I'd rather do that. Thanks a lot for your help!