It is currently April 25th, 2024, 8:50 am

Change theme at a certain time - Honey Skin

Get help with creating, editing & fixing problems with skins
ThePortugueseMan
Posts: 7
Joined: February 27th, 2021, 8:51 pm

Change theme at a certain time - Honey Skin

Post by ThePortugueseMan »

Hey!
I was trying to mod this skin called Honey so it would change its theme throughout the day.

After digging a bit online I came up with this invisible skin:

Code: Select all

[Rainmeter]
 Update=1000
 Group=Honey

[Variables]
 @include=#@#variables.inc

[mTime]
Measure=Time
Format=%M
UpdateDivider=20
IfCondition=((mTime >=4) && (mTime<5))
IfTrueAction=[!WriteKeyValue "Variables" "ThemeName" "morning" "#@#variables.inc"][!Refresh *]
IfCondition1=((mTime>=5) && (mTime<6))
IfTrueAction1=[!WriteKeyValue "Variables" "ThemeName" "noon" "#@#variables.inc"][!Refresh *]

[dummy]
Meter=String
UpdateDivider-1
Note: It's set to change between certain minutes for testing purposes only (so I can see what's happening in a reasonable timeframe). My goal here is to change the theme at a certain time.
Note2: "[!WriteKeyValue "Variables" "ThemeName" "morning" "#@#variables.inc"][!Refresh *]" was already included with a themechanger config file on this skin

This does work but when any one of the conditions are met it consumes a ton of resources and rainmeter becomes very slow.

I've been testing different codes to no avail, so any help would be greatly appreciated!

Thanks in advance
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change theme at a certain time - Honey Skin

Post by balala »

ThePortugueseMan wrote: February 27th, 2021, 9:08 pm This does work but when any one of the conditions are met it consumes a ton of resources and rainmeter becomes very slow.
I suppose that when any of the two conditions is met, you get written the ThemeName variable and get a refresh. When the refresh takes place, you get the variable written once again and a get new refresh. And so on, until the condition becomes false. A refresh doesn't take a minute, so in the minute while the condition is true, you get continuouse refreshes and this is causing the lag. I probably would renonce to the refresh and beside writing the variable would also set it dynamically, with a !SetVariable bang. This way the refresh wouldn't be required anymore. If you want to give it a try, replace the IfTrueAction and IfTrueAction1 option with the following ones (but see below as well): IfTrueAction=[!WriteKeyValue "Variables" "ThemeName" "morning" "#@#variables.inc"][!SetVariable ThemeName "morning"] and IfTrueAction2=[!WriteKeyValue "Variables" "ThemeName" "noon" "#@#variables.inc"][!SetVariable ThemeName "noon"].
Beside this, I doubt the second IfCondition / IfTrueAction (IfCondition1 / IfTrueAction1) option pairs is working, because they should be IfCondition2 / IfTrueAction2. IfCondition1 / IfTrueAction1 don't exist, IfCondition / IfTrueAction should be followed by IfCondition2 / IfTrueAction2.
Also instead of the two posted conditions I'd check simpler conditions, namely these: IfCondition=(mTime=4) and IfCondition2=(mTime=5). These do the same check as the posted much more complicated conditions.
ThePortugueseMan
Posts: 7
Joined: February 27th, 2021, 8:51 pm

Re: Change theme at a certain time - Honey Skin

Post by ThePortugueseMan »

Thank you for the quick reply!

I implemented your suggestions and came up with this:

Code: Select all

[mTime]
Measure=Time
Format=%M
IfCondition=(mtime=54)
IfTrueAction=[!WriteKeyValue "Variables" "ThemeName" "morning" "#@#variables.inc"][!SetVariable ThemeName "morning"]
IfCondition2=(mtime=55)
IfTrueAction2=[!WriteKeyValue "Variables" "ThemeName" "noon" "#@#variables.inc"][!SetVariable ThemeName "noon"]
This doesn't change the theme unless I add [!Refresh *] at the end of each IfTrueAction which causes the initial issue.

It does change the ThemeName in the variables.inc, and if I manually refresh the skin it changes the theme, so all I'm missing is a way to refresh only when the name is changed I think.
balala wrote: February 27th, 2021, 9:40 pmBeside this, I doubt the second IfCondition / IfTrueAction (IfCondition1 / IfTrueAction1) option pairs is working, because they should be IfCondition2 / IfTrueAction2. IfCondition1 / IfTrueAction1 don't exist, IfCondition / IfTrueAction should be followed by IfCondition2 / IfTrueAction2.
Yep, you're right! I fiddled so much with the code I ended up posting a nonworking version
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change theme at a certain time - Honey Skin

Post by balala »

ThePortugueseMan wrote: February 27th, 2021, 11:09 pm I implemented your suggestions and came up with this:

Code: Select all

[mTime]
Measure=Time
Format=%M
IfCondition=(mtime=54)
IfTrueAction=[!WriteKeyValue "Variables" "ThemeName" "morning" "#@#variables.inc"][!SetVariable ThemeName "morning"]
IfCondition2=(mtime=55)
IfTrueAction2=[!WriteKeyValue "Variables" "ThemeName" "noon" "#@#variables.inc"][!SetVariable ThemeName "noon"]
This doesn't change the theme unless I add [!Refresh *] at the end of each IfTrueAction which causes the initial issue.

It does change the ThemeName in the variables.inc, and if I manually refresh the skin it changes the theme, so all I'm missing is a way to refresh only when the name is changed I think.
I don't know what the ThemeName variable does in the rest of your code, so can't say something for sure, but make sure to add a DynamicVariables=1 option to all measures and / or meters which are using it. If still can't get it to work, please post the whole code of your skin, to can see what's happening with the variable.
ThePortugueseMan wrote: February 27th, 2021, 11:09 pm Yep, you're right! I fiddled so much with the code I ended up posting a nonworking version
Don't worry, it happens to all of us, from time to time.
ThePortugueseMan
Posts: 7
Joined: February 27th, 2021, 8:51 pm

Re: Change theme at a certain time - Honey Skin

Post by ThePortugueseMan »

balala wrote: February 28th, 2021, 6:44 am I don't know what the ThemeName variable does in the rest of your code
I believe it ThemeName is what controls the theme to set. It's at variables.inc and when I refresh the skin the theme changes to ThemeName in that file. All the files in this skin that change the theme have this code, [!WriteKeyValue "Variables" "ThemeName" "noon" "#@#variables.inc"][!Refresh *][!ActivateConfig "Honey\themechanger"] not sure if that helps.

I added DynamicVariables=1 to the fixed code I last posted and also in the variables.inc file, but the problem persists. The ThemeName is changed, which is good, but it only updates the theme if I do a manual refresh, or set it to refresh every update (which causes the spike in resource usage)

I've also tried setting IfTrueAction=[!SetVariable ThemeName "morning"], which from what I understand should work with the Dynamic Variables, but I understand very little, and of course it doesn't work xD doesn't even change the ThemeName.

Edit: I discovered I can't use DynamicVariables in [Variables]
Edit2: I think the issues lies in the !WriteKeyvalue. The documentation says that in order to apply the changes made by !WriteKeyvalue the skin must be refreshed.
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change theme at a certain time - Honey Skin

Post by balala »

ThePortugueseMan wrote: February 28th, 2021, 5:24 pm I believe it ThemeName is what controls the theme to set. It's at variables.inc and when I refresh the skin the theme changes to ThemeName in that file. All the files in this skin that change the theme have this code, [!WriteKeyValue "Variables" "ThemeName" "noon" "#@#variables.inc"][!Refresh *][!ActivateConfig "Honey\themechanger"] not sure if that helps.
No, it really doesn't, but see below.
Note that the !ActivateConfig really requires two parameters: the name of the config which contains the skin you want to load (this is added) and the name of the skin, which has to be activated (this isn't). However the bang works even with one single parameter, the name of the config, because in such cases it activates (loads) the first skin of the config (if no skin is activated) or the next one (if a skin is already activated).
ThePortugueseMan wrote: February 28th, 2021, 5:24 pm Edit: I discovered I can't use DynamicVariables in [Variables]
It can be used ONLY on measures and meters, having set the DynamicVariables=1 option.
ThePortugueseMan wrote: February 28th, 2021, 5:24 pm Edit2: I think the issues lies in the !WriteKeyvalue. The documentation says that in order to apply the changes made by !WriteKeyvalue the skin must be refreshed.
Yes, that's right, but if you add both bangs, a !WriteKeyValue and a !SetVariable, you do two operations: you write the new value of the variable into the [Variables] section (so this way after a refresh you don't get lost the variable) and you set it dynamically, to can immediatelly use it into a meter or measure, without having to refresh the skin. That's why I said you to add a DynamicVariables=1 option to the meter or measure where you want to use the variable.

Ok, in order to can help you more, please pack the whole config you're working with (simply posting the code is not enough probably, because there are some other needed files as well) and upload the package here. This way I'm gonna have all needed files to see what's going on.
ThePortugueseMan
Posts: 7
Joined: February 27th, 2021, 8:51 pm

Re: Change theme at a certain time - Honey Skin

Post by ThePortugueseMan »

balala wrote: February 28th, 2021, 6:31 pmNote that the !ActivateConfig really requires two parameters: the name of the config which contains the skin you want to load (this is added) and the name of the skin, which has to be activated (this isn't). However the bang works even with one single parameter, the name of the config, because in such cases it activates (loads) the first skin of the config (if no skin is activated) or the next one (if a skin is already activated).
I think that part of the code is used just to activate an icon as removing it just removes the creation of said icon.
balala wrote: February 28th, 2021, 6:31 pmOk, in order to can help you more, please pack the whole config you're working with (simply posting the code is not enough probably, because there are some other needed files as well) and upload the package here. This way I'm gonna have all needed files to see what's going on.
Thank you so much for your help! Here it is. The changes I've made to the original files (besides adding icons) was adding some themes in @Resources/themes and also added themechanger\themechanger.dawn.ini for testing purposes.
Also I'm using the .ini file for a clock that came with the skin to write the code, so I put the original back in \time just in case. Finally all my tests have been done in \time\time.only.ini

Meanwhile I've been trying to cheese it a little bit:

Code: Select all

[Variables]
temp=0
@include=#@#variables.inc

[mTime]
Measure=Time
Format=%M
IfCondition=(mtime=23) && (temp!=1)
IfTrueAction=[!WriteKeyValue "Variables" "ThemeName" "morning" "#@#variables.inc"][!Refresh *]
IfTrueAction=(temp=1)
IfCondition2=(mtime=24) && (temp!=2)
IfTrueAction2=[!WriteKeyValue "Variables" "ThemeName" "noon" "#@#variables.inc"][!Refresh *]
IfTrueAction2=(temp=2)

[dummy]
Meter=String
UpdateDivider-1
I'm not sure if it's worth doing something like this, but as of now it doesn't work, surprise, surprise.. :(
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change theme at a certain time - Honey Skin

Post by balala »

ThePortugueseMan wrote: February 28th, 2021, 8:06 pm Here it is.
Sorry, but I can't and won't start to download all those files one by one. Please pack the whole config into a .zip, .rar or .rmskin (or whetever) package and upload it. You canb upload it right here, no need to use Google Drive or whatever else. Have to go down, below the field where you are writing your reply and click the Attachements tab, then to the Add files button:
Attachements.png
You do not have the required permissions to view the files attached to this post.
ThePortugueseMan
Posts: 7
Joined: February 27th, 2021, 8:51 pm

Re: Change theme at a certain time - Honey Skin

Post by ThePortugueseMan »

balala wrote: February 28th, 2021, 8:36 pm Sorry, but I can't and won't start to download all those files one by one. Please pack the whole config into a .zip, .rar or .rmskin (or whetever) package and upload it. You canb upload it right here, no need to use Google Drive or whatever else. Have to go down, below the field where you are writing your reply and click the Attachements tab, then to the Add files button:
Attachements.png
No need to apologize it was my bad! Sorry. Hopefully everything works out now.
Everything I said before stills stands but now there's an extra folder named ".vs" that was created by Visual Studio, so it shouldn't matter.
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change theme at a certain time - Honey Skin

Post by balala »

ThePortugueseMan wrote: February 28th, 2021, 10:29 pm No need to apologize it was my bad! Sorry. Hopefully everything works out now.
Everything I said before stills stands but now there's an extra folder named ".vs" that was created by Visual Studio, so it shouldn't matter.
Now having the package, I think the !SetVariable solution was a bad idea.
What would I try is to slightly modify the [mTime] measure in a way to have the variable writing applied only once, not more times in the appropriate minute. For instance this way:

Code: Select all

[mTime]
Measure=Time
Format=%M.%S
;UpdateDivider=20
IfCondition=(mTime=4)
IfTrueAction=[!WriteKeyValue "Variables" "ThemeName" "morning" "#@#variables.inc"][!Refresh *]
IfCondition1=(mTime=5)
IfTrueAction1=[!WriteKeyValue "Variables" "ThemeName" "noon" "#@#variables.inc"][!Refresh *]
Take care that I removed (commented out) the UpdateDivider option. Also modified a little bit the Format option, in a way to get returned a decimal number. Now the equality used in the IfCondition options is true only for a second and the writing of the variable happens only once. Hope it does work well. Does it?