It is currently May 17th, 2024, 5:32 am

Hacking together a battery skin

Get help with creating, editing & fixing problems with skins
1Ro­gue
Posts: 3
Joined: November 6th, 2012, 9:12 pm

Hacking together a battery skin

Post by 1Ro­gue »

tl;dr of my questions:
1) Can I use nested ternary statements?
2) Would such a statement for rainmeter look like:

Code: Select all

[Variables]
Percent=MeasureCurrentColor
Color=(#Percent# < 10 ? "FF0000" : (#Percent# < 20 ? "FF8000" : "008800"))
So using a battery skin that I've had for a while, I decided to try and hack together some basics on Rainmeter. I understand a lot of it, doing programming before definitely helped. One hurdle I'm not easily getting by is attempting to dynamicly update the color of the battery meter via the percentage it is at. I was considering updating using the "status" feature of the battery plugin (charging, not charging, high, low, critical), using lines like so:

Code: Select all

[MeasureCurrentColor]
Measure=Plugin
Plugin=Plugins\PowerPlugin.dll
PowerState=STATUS
Substitute="0":"FF8000","1":"008800","2":"FF0000","3":"FF8000","4":"008800"
UpdateDivider=60

[Robe]
Meter=Bar
BarColor=MeasureCurrentColor
(The measuring of the bar is working fine, so I excluded it). Full code is here: http://pastebin.com/raw.php?i=CydPjQ5c
Creator info wasn't changed, one similar to the original is here: http://browse.deviantart.com/?q=battery+rainmeter#/d4yl3n7

As for the output, my issue was that it is producing the default color (255, 255, 255, 255 in rgb). At that point I knew I had two problems.

1) It should have at least produced a colored output, regardless of what it was, if it had supported hex colors.
2) Because the plugin I'm currently using doesn't have proper values for finding high/low/critical status of the battery, I considered doing it by percents.

Code: Select all

[MeasureCurrentColor]
Measure=Plugin
Plugin=Plugins\PowerPlugin.dll
PowerState=PERCENT
Substitute="0":"FF8000","1":"008800","2":"FF0000","3":"FF8000","4":"008800"
UpdateDivider=60

[Robe]
Meter=Bar
BarColor=MeasureCurrentColor
Thus fixing the issue of using the statuses, however I'm unsure of what way I would need to update the values without replacing every number. Nested ternary statements in some languages can be buggy, so is it okay to use in Rainmeter?
1Ro­gue
Posts: 3
Joined: November 6th, 2012, 9:12 pm

Re: Hacking together a battery skin

Post by 1Ro­gue »

Fixed my own issue with the color :) Looks like an rgb input finally did it, I was just too preferrable to hex.
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: Hacking together a battery skin

Post by Seahorse »

When substituting colours, you should use negative numbers because they cannot exist in colour codes. More details here.
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt