It is currently April 24th, 2024, 11:00 am

Calc with freediskspace

Get help with creating, editing & fixing problems with skins
swagginnate
Posts: 12
Joined: February 11th, 2018, 8:25 am

Calc with freediskspace

Post by swagginnate »

Im trying to manually calculate the percentage of used disk space so i can use a shape meter rather than a bar. I can get the total space and the used space, and separately they appear fine, but if i use them together in a calc formula rainmeter messes up and thinks theyre the same value.
This code takes useddisk/totaldisk but it always feeds back as 1
Ideally it would feed back as a number between 0 and 1

Code: Select all

[background]
meter=shape
shape=rectangle 0,0,200,80| fillcolor 255,255,255,255

[measureTotalDisk1]
Measure=FreeDiskSpace
Drive=c:
Total=1

[measureUsedDisk1]
Measure=FreeDiskSpace
Drive=c:
InvertMeasure=1

[useddisk1string]
meter=string
measurename=measureusedDisk1

[divisionsymbol]
meter=string
text=/
y=16

[totaldiskstring]
meter=string
measurename=measuretotaldisk1
y=32

[equalssymbol]
meter=string
text==
y=48

[diskusage]
measure=calc
formula=(measureuseddisk1) / (measuretotaldisk1)
dynamicvariables=1

[answer]
meter=string
measurename=diskusage
y=64
dynamicvariables=1
Last edited by swagginnate on February 11th, 2018, 9:36 am, edited 1 time in total.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Calc with freediskspace

Post by mak_kawa »

For example...

Code: Select all

[answer]
meter=string
measurename=diskusage
y=64
NumOfDecimals=4
dynamicvariables=1
swagginnate
Posts: 12
Joined: February 11th, 2018, 8:25 am

Re: Calc with freediskspace

Post by swagginnate »

Thank you!
User avatar
balala
Rainmeter Sage
Posts: 16164
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Calc with freediskspace

Post by balala »

Just to detail a bit, the [diskusage] Calc measure indeed returns a number between 0 and 1, but by default a String meter which shows its value, shows that value rounded, with no decimals. That's why mak_kawa added the NumOfDecimals=4 option to the [answer] String meter. With this option added, the meter will show up 4 decimals.
However the value returned by the [diskusage] measure can be used with no problems, eg in any meter which requires percentual values (eg a Bar meter). And for this you don't even have to set the MinValue and MaxValue on this measure (as you should have to do if the limits of the measure would be any others), because their values by default are 0 and 1 accordingly, which correspond to the limits of the value returned by the [diskusage] measure.