It is currently September 29th, 2024, 11:14 pm

Virtual Desktop dynamic color change

General topics related to Rainmeter.
onani_master
Posts: 7
Joined: August 12th, 2012, 3:09 pm

Virtual Desktop dynamic color change

Post by onani_master »

Hi folks, I'm making a simple desktop switcher for "VirtuaWin" and using info from here: http://rainmeter.net/cms/Plugins-VirtualDesktops

At this moment I have 4 virtual desktops at VirtuaWin and made simple test skin for switching them by clicking on image background:
1.jpg
Current skin code is:

Code: Select all

[Rainmeter]
Update=1000

[Variables]
FontName=calibry
FontHeight=8

Color_1=1, 1, 1
Color_2=255,255,255

Switch1=!RainmeterPluginBang "SwitchDesktop 1"
Switch2=!RainmeterPluginBang "SwitchDesktop 2"
Switch3=!RainmeterPluginBang "SwitchDesktop 3"
Switch4=!RainmeterPluginBang "SwitchDesktop 4"

;======================

[CurrentDesktop]
Measure=Plugin
Plugin=VirtualDesktops.dll
VDManager=VirtuaWin
VDMeasureType=CurrentDesktop

[SwitchDesktop]
Measure=Plugin
Plugin=VirtualDesktops.dll
VDManager=VirtuaWin
VDMeasureType=SwitchDesktop

;======================

[Background_1]
Meter=IMAGE
X=0
Y=5
H=20
W=100
SolidColor=#Color_1#
LeftMouseUpAction=!Execute [#Switch1#]
MouseActionCursor=1

[Label_1]
Meter=STRING
X=50
Y=8
FontColor=#Color_2#
FontFace=#FontName#
FontSize=#FontHeight#
Text="Desktop_Name_1"
StringAlign=Center

[Background_2]
Meter=IMAGE
X=110
Y=5
H=20
W=100
SolidColor=#Color_1#
LeftMouseUpAction=!Execute [#Switch2#] 
MouseActionCursor=1

[Label_2]
Meter=STRING
X=160
Y=8
FontColor=#Color_2#
FontFace=#FontName#
FontSize=#FontHeight#
Text="Desktop_Name_2"
StringAlign=Center

[Background_3]
Meter=IMAGE
X=220
Y=5
H=20
W=100
SolidColor=#Color_1#
LeftMouseUpAction=!Execute [#Switch3#] 
MouseActionCursor=1

[Label_3]
Meter=STRING
X=270
Y=8
FontColor=#Color_2#
FontFace=#FontName#
FontSize=#FontHeight#
Text="Desktop_Name_4"
StringAlign=Center	

[Background_4]
Meter=IMAGE
X=330
Y=5
H=20
W=100
SolidColor=#Color_1#
LeftMouseUpAction=!Execute [#Switch4#] 
MouseActionCursor=1

[Label_4]
Meter=STRING
X=380
Y=8
FontColor=#Color_2#
FontFace=#FontName#
FontSize=#FontHeight#
Text="Desktop_Name_4"
StringAlign=Center
And here is my question: can I somehow make current selected desktop based on CurrentDesktop to use different color for text and background?

For instance if CurrentDesktop is 2 than set color at [Background_2] to #Color_1# and at [Label_2] set color to "#Color_2#" or something like this and at the end it would look like something like this:
2.jpg
The problem is I don't know how to properly organize this code and hope you will help me with this. Thanks!
You do not have the required permissions to view the files attached to this post.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Virtual Desktop dynamic color change

Post by smurfier »

Try this:

Code: Select all

[Rainmeter]
Update=1000

[Variables]
Color_1=1, 1, 1
Color_2=255,255,255


;======================

[CurrentDesktop]
Measure=Plugin
Plugin=VirtualDesktops.dll
VDManager=VirtuaWin
VDMeasureType=CurrentDesktop

[SwitchDesktop]
Measure=Plugin
Plugin=VirtualDesktops.dll
VDManager=VirtuaWin
VDMeasureType=SwitchDesktop

;======================

[LabelStyle]
X=50r
Y=8
FontColor=#Color_2#
FontFace=clibry
FontSize=8
StringAlign=Center

[BackgroundStyle]
Y=5
H=20
W=100
SolidColor=#Color_1#

[Background_1]
Meter=IMAGE
MeterStyle=BackgroundStyle
X=0
LeftMouseUpAction=!CommandMeasure SwitchDesktop 1

[Label_1]
Meter=STRING
MeterStyle=LabelStyle
Text="Desktop_Name_1"

[Background_2]
Meter=IMAGE
X=110
MeterStyle=BackgroundStyle
LeftMouseUpAction=!CommandMeasure SwitchDesktop 2

[Label_2]
Meter=STRING
MeterStyle=LabelStyle
Text="Desktop_Name_2"

[Background_3]
Meter=IMAGE
X=220
MeterStyle=BackgroundStyle
LeftMouseUpAction=!CommandMeasure SwitchDesktop 3

[Label_3]
Meter=STRING
MeterStyle=LabelStyle
Text="Desktop_Name_3" 

[Background_4]
Meter=IMAGE
X=330
MeterStyle=BackgroundStyle
LeftMouseUpAction=!CommandMeasure SwitchDesktop 4

[Label_4]
Meter=STRING
MeterStyle=LabelStyle
Text="Desktop_Name_4"

[CurrentBack]
Meter=IMAGE
MeterStyle=BackgroundStyle
X=(110*([CurrentDesktop]-1))
SolidColor=#Color_2#
DynamicVariables=1

[CurrentLabel]
Meter=STRING
MeterStyle=LabelStyle
MeasureName=CurrentDesktop
Text=Desktop_Name_%1
FontColor=#Color_1#
  1. !RainmeterPluginBang was depreciated in favor of !CommandMeasure.
  2. I changed your code to use MeterStyles.
  3. Instead of changing existing meters, it's easier to just create a specific meter just for displaying which one is current.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
onani_master
Posts: 7
Joined: August 12th, 2012, 3:09 pm

Re: Virtual Desktop dynamic color change

Post by onani_master »

Works perfectly, thank you very much, man!
onani_master
Posts: 7
Joined: August 12th, 2012, 3:09 pm

Re: Virtual Desktop dynamic color change

Post by onani_master »

One more question, what if I change my desktop labels instead of "Destkop_Number_1", "Destkop_Number_2" and so forth, to something like "Main", "Web", "Media", "Work", and now based on "[CurrentLabel]" it shows "Desktop_Name_%" text at current desktop.
Can I somehow make it use same text for "CurrentLabel" as in "DesktopLabel" like "Work" instead of "Desktop_Name_4"?

Code is same as provided to me by smurfier, with changed only labels of desktops. Thanks!

Code: Select all

[Rainmeter]
Update=1000

[Variables]
Color_1=1, 1, 1
Color_2=255,255,255


;======================

[CurrentDesktop]
Measure=Plugin
Plugin=VirtualDesktops.dll
VDManager=VirtuaWin
VDMeasureType=CurrentDesktop

[SwitchDesktop]
Measure=Plugin
Plugin=VirtualDesktops.dll
VDManager=VirtuaWin
VDMeasureType=SwitchDesktop

;======================

[LabelStyle]
X=50r
Y=8
FontColor=#Color_2#
FontFace=clibry
FontSize=8
StringAlign=Center

[BackgroundStyle]
Y=5
H=20
W=100
SolidColor=#Color_1#

[Background_1]
Meter=IMAGE
MeterStyle=BackgroundStyle
X=0
LeftMouseUpAction=!CommandMeasure SwitchDesktop 1

[Label_1]
Meter=STRING
MeterStyle=LabelStyle
Text="Main"

[Background_2]
Meter=IMAGE
X=110
MeterStyle=BackgroundStyle
LeftMouseUpAction=!CommandMeasure SwitchDesktop 2

[Label_2]
Meter=STRING
MeterStyle=LabelStyle
Text="Web"

[Background_3]
Meter=IMAGE
X=220
MeterStyle=BackgroundStyle
LeftMouseUpAction=!CommandMeasure SwitchDesktop 3

[Label_3]
Meter=STRING
MeterStyle=LabelStyle
Text="Media"

[Background_4]
Meter=IMAGE
X=330
MeterStyle=BackgroundStyle
LeftMouseUpAction=!CommandMeasure SwitchDesktop 4

[Label_4]
Meter=STRING
MeterStyle=LabelStyle
Text="Work"

[CurrentBack]
Meter=IMAGE
MeterStyle=BackgroundStyle
X=(110*([CurrentDesktop]-1))
SolidColor=#Color_2#
DynamicVariables=1

[CurrentLabel]
Meter=STRING
MeterStyle=LabelStyle
MeasureName=CurrentDesktop
Text=Desktop_Name_%1
FontColor=#Color_1#
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5534
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Virtual Desktop dynamic color change

Post by eclectic-tech »

Add a substitution line to your measure...

Code: Select all

[CurrentDesktop]
Measure=Plugin
Plugin=VirtualDesktops.dll
VDManager=VirtuaWin
VDMeasureType=CurrentDesktop
Substitute="1":"Main","2":"Web","3":"Media","4":"Work"
This should return the name rather than the number.

On the Current label meter you can eliminate the Text= line or change it to Text=%1

Code: Select all

[CurrentLabel]
Meter=STRING
MeterStyle=LabelStyle
MeasureName=CurrentDesktop
Text=%1
FontColor=#Color_1#
Haven't tried this, but it should work. :uhuh:
onani_master
Posts: 7
Joined: August 12th, 2012, 3:09 pm

Re: Virtual Desktop dynamic color change

Post by onani_master »

Thanks for help! It worked, but for some reason when I add substitute to "[CurrentDesktop]" my desktop background stopped switching, when I'm changing between desktops and always stays at desktop_1 / "main". What I've done is simply made copy of "[CurrentDesktop]" but without substitute and tell "[CurrentBack]" to use this copied CurrentDesktop measure , maybe there is a better solution for this but it works. Again thanks for help!
Here's my final code:

Code: Select all

[Rainmeter]
Update=1000

[Variables]
Color_1=27, 27, 27
Color_2=180, 180, 180


;======================

[CurrentDesktop1]
Measure=Plugin
Plugin=VirtualDesktops.dll
VDManager=VirtuaWin
VDMeasureType=CurrentDesktop
Substitute="1":"Main","2":"Web","3":"Media","4":"Work"

[CurrentDesktop2]
Measure=Plugin
Plugin=VirtualDesktops.dll
VDManager=VirtuaWin
VDMeasureType=CurrentDesktop

[SwitchDesktop]
Measure=Plugin
Plugin=VirtualDesktops.dll
VDManager=VirtuaWin
VDMeasureType=SwitchDesktop

;======================

[LabelStyle]
X=50r
Y=8
FontColor=#Color_2#
FontFace=cure
FontSize=7
StringAlign=Center

[BackgroundStyle]
Y=5
H=20
W=100
SolidColor=#Color_1#

[Background_1]
Meter=IMAGE
MeterStyle=BackgroundStyle
X=0
LeftMouseUpAction=!CommandMeasure SwitchDesktop 1

[Label_1]
Meter=STRING
MeterStyle=LabelStyle
Text="Main"

[Background_2]
Meter=IMAGE
X=110
MeterStyle=BackgroundStyle
LeftMouseUpAction=!CommandMeasure SwitchDesktop 2

[Label_2]
Meter=STRING
MeterStyle=LabelStyle
Text="Web"

[Background_3]
Meter=IMAGE
X=220
MeterStyle=BackgroundStyle
LeftMouseUpAction=!CommandMeasure SwitchDesktop 3

[Label_3]
Meter=STRING
MeterStyle=LabelStyle
Text="Media"

[Background_4]
Meter=IMAGE
X=330
MeterStyle=BackgroundStyle
LeftMouseUpAction=!CommandMeasure SwitchDesktop 4

[Label_4]
Meter=STRING
MeterStyle=LabelStyle
Text="Work"

[CurrentBack]
Meter=IMAGE
MeterStyle=BackgroundStyle
X=(110*([CurrentDesktop2]-1))
SolidColor=#Color_2#
DynamicVariables=1

[CurrentLabel]
Meter=STRING
MeterStyle=LabelStyle
MeasureName=CurrentDesktop1
Text=%1
FontColor=#Color_1#
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Virtual Desktop dynamic color change

Post by smurfier »

What happened is that we were using the number for a calculation and the substitute changed it to a string. Luckily the number is still there we just have to tell Rainmeter that it's what we want to use.

In the [CurrentBack] meter, just change this one line:
X=(110*([CurrentDesktop:]-1))

By adding a colon to the end of the Section Variable we are using the Number value instead of the string.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .