It is currently May 3rd, 2024, 8:27 am

[SOLVED] Conditional help with Illustro disk

Get help with creating, editing & fixing problems with skins
jvdubn
Posts: 2
Joined: June 9th, 2011, 1:24 am

[SOLVED] Conditional help with Illustro disk

Post by jvdubn »

I am new to rainmeter so if I am not providing the right information, let me know. I am trying to write a conditional for illustro disk. The way the code behaves currently If the drive is unavailable then 0.0B/0.0B used is displayed. basically I want it to show removable drive information when the drive is plugged in and some message when the drive is not plugged in. I think my understanding of conditionals may be off because its not working. Here is the full code: :confused:

Code: Select all

; Lines starting ; (semicolons) are commented out.
; That is, they do not affect the code and are here for demonstration purposes only.
; ----------------------------------

; NOTE! If you want to add more disks, take a look at 'Disks 2.ini'.

[Rainmeter]
; This section contains general settings that can be used to change how Rainmeter behaves.
Author=poiru
AppVersion=1003000
Update=1000

[Metadata]
; Contains basic information of the skin.
Name=Disk
Description=Displays the usage of your disks.
License=Creative Commons BY-NC-SA 3.0
Version=1.0.0

[Variables]
; Variables declared here can be used later on between two # characters (e.g. #MyVariable#).
fontName=Trebuchet MS
textSize=8
colorBar=235,170,0,255
colorText=255,255,255,205
disk1=C:

; ----------------------------------
; MEASURES return some kind of value
; ----------------------------------

[measureTotalDisk1]
; This measure returns the total disk space
Measure=FreeDiskSpace
Drive=#disk1#
Total=1
UpdateDivider=120

[measureUsedDisk1]
; Returns inverted value of free disk space (i.e. used disk space)
Measure=FreeDiskSpace
Drive=#disk1#
InvertMeasure=1
UpdateDivider=120

; ----------------------------------
; STYLES are used to "centralize" options
; ----------------------------------

[styleTitle]
StringAlign=CENTER
StringCase=UPPER
StringStyle=BOLD
StringEffect=SHADOW
FontEffectColor=0,0,0,50
FontColor=#colorText#
FontFace=#fontName#
FontSize=10
AntiAlias=1
ClipString=1

[styleLeftText]
StringAlign=LEFT
; Meters using styleLeftText will be left-aligned.
StringCase=NONE
StringStyle=BOLD
StringEffect=SHADOW
FontEffectColor=0,0,0,20
FontColor=#colorText#
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

[styleRightText]
StringAlign=RIGHT
StringCase=NONE
StringStyle=BOLD
StringEffect=SHADOW
FontEffectColor=0,0,0,20
FontColor=#colorText#
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

[styleBar]
BarColor=#colorBar#
BarOrientation=HORIZONTAL
SolidColor=255,255,255,15

; ----------------------------------
; METERS display images, text, bars, etc.
; ----------------------------------

[meterBackground]
Meter=IMAGE
ImageName=#SKINSPATH#\illustro\SHARED\Background1Line.png
; #SKINSPATH# is a global variable that stands for your skin path. It is
; usually Documents\Rainmeter\Skins.
X=0
Y=0

[meterTitle]
Meter=STRING
MeterStyle=styleTitle
; Using MeterStyle=styleTitle will basically "copy" the
; contents of the [styleTitle] section here during runtime.
X=100
Y=12
W=190
H=18
Text="Disks"
; Even though the text is set to Disks, Rainmeter will display
; it as DISKS, because styleTitle contains StringCase=UPPER.

[meterLabelDisk1]
Meter=STRING
MeterStyle=styleLeftText
X=10
Y=40
W=190
H=14
Text="#disk1#\"

[meterValueDisk1]
Meter=STRING
MeterStyle=styleRightText
MeasureName=measureUsedDisk1
MeasureName2=measureTotalDisk1
X=200
Y=0r
; r stands for relative. In this case, the Y postition of meterValueCPU is 0 pixels
; below the Y value of the previous meter (i.e it's the same as in meterLabelCPU).
W=190
H=14
;conditional needs to go here to only display if the drive is larger than 0.0
;This is how i think it should go but its not working
;MeasureName2 > 0.0 ? Text="%1B/%2B used" :  Text="Unplugged" 
Text="%1B/%2B used" ;<< i only want this to execute if there is a drive.
; %1 stands for the value of MeasureName (measureUsedDisk1 in this case).
; %2 stands for the value of MeasureName2.
NumOfDecimals=1
AutoScale=1
; Because disk measures return the free/used space in bytes, we must use AutoScale=1 to
; automatically scale the value into a more readable figure.
LeftMouseUpAction=!Execute ["#disk1#\"]
; Open #disk1# on click

[meterBarDisk1]
Meter=BAR
MeterStyle=styleBar
MeasureName=measureUsedDisk1
X=10
Y=52
W=190
H=1
this is the part of the code that I think needs changed to accomplish this:

Code: Select all

;conditional needs to go here to only display if the drive is larger than 0.0
;This is how i think it should go but its not working
;MeasureName2 > 0.0 ? Text="%1B/%2B used" :  Text="Unplugged" 
Text="%1B/%2B used" ;<< i only want this to execute if there is a drive.
You do not have the required permissions to view the files attached to this post.
Last edited by jvdubn on June 9th, 2011, 6:07 pm, edited 1 time in total.
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: *Conditional help with Illustro disk

Post by Kaelri »

Conditionals are only used in CALC measures, which are meant to manipulate data from other measures to do this exact sort of thing. (Clever idea, actually - I might borrow it. :)

Because "meterValueDisk1" is using multiple MeasureNames, it would be a little complicated to do this with a single conditional. A much easier method is to put your "Unplugged" text in a completely separate meter, then show or hide that meter depending on the disk space.

First, add this measure under [measureUsedDisk1]:

Code: Select all

[measureCheckUnplugged]
; This measure returns a different value based on whether the disk shows free space available.
Measure=CALC
Formula=measureTotalDisk1 > 0
IfEqualValue=0
IfEqualAction=!Execute [!RainmeterHideMeter meterValueDisk1][!RainmeterShowMeter meterValueDisk1unplugged]
IfAboveValue=0
IfAboveAction=!Execute [!RainmeterShowMeter meterValueDisk1][!RainmeterHideMeter meterValueDisk1unplugged]
; If the total disk space is reported as 0, the normal "X/Y used" text will be hidden, and a new meter with the text "Unplugged" will be shown. If it's above 0, the opposite happens.
Then, add this meter under [meterValueDisk1]:

Code: Select all

[meterValueDisk1unplugged]
; This meter is a duplicate of the previous meter, just with different text. It will only appear if the disk space is reported as 0.
Meter=STRING
MeterStyle=styleRightText
X=200
Y=r
W=190
H=14
Text="Unplugged"
Hidden=1
jvdubn
Posts: 2
Joined: June 9th, 2011, 1:24 am

Re: *Conditional help with Illustro disk

Post by jvdubn »

Thanks Kaelri you have been most helpful.
If anyone is considering implementing this change.
I did have to manually match the y= value with the corresponding disk meter. The y=r was using the relative position of the hidden meter and displaying under the hidden meter like the picture shows. I couldn't think of another way. I hope this doesn't produce any other issues as it works fine now.

Again thanks for your help, :thumbup:
You do not have the required permissions to view the files attached to this post.
User avatar
Hawkie
Posts: 6
Joined: August 8th, 2011, 6:55 pm
Location: south England, UK

Re: [SOLVED] Conditional help with Illustro disk

Post by Hawkie »

This code is great managed to get it working but I have to manually refresh the skin after I turn my external hard drive on and off, is there a way so that it refresh automatically to see if it is still plugged in?

A reply would be welcome an answer would be gratefully received.