It is currently April 24th, 2024, 1:44 pm

Swapping configs based on resolution changes

Tips and Tricks from the Rainmeter Community
kati42
Posts: 35
Joined: May 4th, 2009, 4:25 am

Swapping configs based on resolution changes

Post by kati42 »

There are a few reasons why one might want to swap configs based on a change in resolution. Perhaps you have a laptop, and you hook it up to a higher-resolution monitor at either work or home. Perhaps you have a tablet, and you switch between portrait and landscape views. Perhaps you rotate your external monitor between portrait and landscape. Maybe all of the above.

Here is an example of how to detect the horizontal resolution (screen width), and swap between two configs accordingly. I have attached all files to this post. Basically, there is a "main" config that doesn't actually contain any visible meters - its only purpose is to activate and deactivate the other two configs, each of which is located in its own subdirectory. To avoid a warning when choosing the main config, I put a hidden meter in it.

The directory structure of this example is:
Outer directory, goes in Skins directory: Swapconfig\
Main config file that should be selected in Rainmeter: Swapconfig\Swapconfig.ini
One of the two configs to swap between: Swapconfig\Config1\Config1.ini
The other config to swap between: Swapconfig\Config2\Config2.ini

The code for the main config (the one that controls the swapping is:

Code: Select all

[Rainmeter]
Author=kati42
Update=500

;----------------------------------
; Screen Resolution Control
;----------------------------------

[MeasureScreenWidth]
Measure=Plugin
Plugin=Plugins\SysInfo.dll
SysInfoType=SCREEN_WIDTH
SysInfoData=1
IfEqualValue=1280
IfEqualAction=!Execute [!RainmeterActivateConfig Swapconfig\Config1 Config1.ini] [!RainmeterDeactivateConfig Swapconfig\Config2 Config2.ini]
IfBelowValue=1280
IfBelowAction=!Execute [!RainmeterActivateConfig Swapconfig\Config2 Config2.ini] [!RainmeterDeactivateConfig Swapconfig\Config1 Config1.ini]

[Meter]
Meter=IMAGE
X=0
Y=0
W=16
H=16
SolidColor="0,0,0,255"
Hidden=1
This example shows Config1 when the horizontal screen resolution is 1280, and Config2 when it's less than 1280. This corresponds to landscape (Config1) and Portrait (Config2) on my 1280x800 tablet. The behavior when the resolution is above 1280 is not defined for this example, but you could add an IfAboveValue=1280 and an IfAboveAction sequence that, for example, deactivates both Config1 and Config2. If you add a third config for resolutions wider than 1280, don't forget to deactivate it in the IfEqualAction and IfBelowAction, and to deactivate Config1 and Config2 in the IfAboveAction.

When the updated DesktopCoral (an application to reserve space at the sides of the desktop) is posted that lets you send command-line options to set its location and size, I'll post another example that uses that in conjunction with swapping Rainmeter configs...
dragonmage
Developer
Posts: 1270
Joined: April 3rd, 2009, 4:31 am
Location: NC, US

Re: Swapping configs based on resolution changes

Post by dragonmage »

You know, I just thought of an alternate method for doing this that would eliminate the need for DesktopCoral. I don't know if you have been following development of jsmorley's RainThemes app.

You could use it to change "themes" when the resolution changes, and since you'd be using two different Rainmeter.ini files you could use Rainmeter's own DesktopWorkArea setting to change the reserved screen space for each theme.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Swapping configs based on resolution changes

Post by jsmorley »

dragonmage wrote:You know, I just thought of an alternate method for doing this that would eliminate the need for DesktopCoral. I don't know if you have been following development of jsmorley's RainThemes app.

You could use it to change "themes" when the resolution changes, and since you'd be using two different Rainmeter.ini files you could use Rainmeter's own DesktopWorkArea setting to change the reserved screen space for each theme.
And RainThemes can be driven by the command line, so you could do a !execute command to load a theme...

So you save one copy of your setup all positioned for one resolution, and another copy set up for the other resolution, and just do a !execute to load the one you want at any given time.
kati42
Posts: 35
Joined: May 4th, 2009, 4:25 am

Re: Swapping configs based on resolution changes

Post by kati42 »

That sounds like I'd have to run it as administrator in Vista...
dragonmage
Developer
Posts: 1270
Joined: April 3rd, 2009, 4:31 am
Location: NC, US

Re: Swapping configs based on resolution changes

Post by dragonmage »

Not sure.
sgtevmckay

Re: Swapping configs based on resolution changes

Post by sgtevmckay »

Interesting

All I can say is try it and let us know the results 8-)
KiRe
Posts: 35
Joined: July 25th, 2009, 5:49 am
Location: USA

Re: Swapping configs based on resolution changes

Post by KiRe »

Anyone know if this would work *immediately* when you start Rainmeter or bring the computer out of sleep? So no skins would be changed until the swap config refreshed.

Because the problem i potentially see is, if you closed rainmeter or put your computer to sleep with the higher resolution setting, and then opened rainmeter or brought the cmoputer out of sleep with the lower resolution, it would load all the skins on the previous settings, but because of the resolution change, it would move everything, thus defeating the purpose...

Don't get me wrong, I really want to use this config, but wanted to make sure it would work in this situation... which I find myself in quite often.

Edit: Re-read what i wrote... and re-wrote it to make sense... >.<
Last edited by KiRe on July 31st, 2009, 11:47 pm, edited 1 time in total.
^ rainmeter noob.
KiRe
Posts: 35
Joined: July 25th, 2009, 5:49 am
Location: USA

Re: Swapping configs based on resolution changes

Post by KiRe »

Just tried using this and it does NOT work in rainmeter 0.14 unless i'm missing an extra plugin... are you using a beta version?
^ rainmeter noob.
dragonmage
Developer
Posts: 1270
Joined: April 3rd, 2009, 4:31 am
Location: NC, US

Re: Swapping configs based on resolution changes

Post by dragonmage »

Considering that she has the resolution checked every half second, it should be changing as soon as the resolution changes.
kati42
Posts: 35
Joined: May 4th, 2009, 4:25 am

Re: Swapping configs based on resolution changes

Post by kati42 »

I am using the beta, yes. I have not tried it lately to see if the sleep/reboot is a problem. (I have been busy, and need to figure out a couple things to make it work the way I want first). But depending on which sides you're using, you could also have a "refresh" button at 0,0 or something. I know it's not as clean as an automatic solution...