It is currently April 19th, 2024, 2:30 pm

autodetecting disks - if disk exist then add to skin... is this possible?

Get help with creating, editing & fixing problems with skins
RogerDingo
Posts: 14
Joined: February 6th, 2020, 4:11 pm

autodetecting disks - if disk exist then add to skin... is this possible?

Post by RogerDingo »

hi all

im looking for a way to edit the disks skin so that it updates and displays meters for disks that are actually on a server.
so at the moment the default disks skin has 2 ini files.

1 Disk.ini
2 Disk.ini

i added a 3rd disk to the server and the only way to add a new meter was to modify 2 Disk.ini and create a new ini file.. called...

3 Disk.ini

if the disk is removed the 3rd meter still reports the disk but as 0


so is there a way to have the skins auto detect how many disks are on a server and auto populate the skin according to the number of disks it has detected?

im thinking maybe a IF THEN statement might be the way to go...
very basic thinking....

Code: Select all

IF disk 1 detected
then 
create meter for disk 1

IF disk 2 detected
then 
create meter for disk 2

IF disk 3 detected
then 
create meter for disk 3
something along those lines...

i can see there are some IF condition options available...
or maybe dynamic variables or some other option?
maybe this has already been done and a skin exists.. but i havent been able to locate it as yet...

any help and suggestions will be greatly appreciated!


thanks
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: autodetecting disks - if disk exist then add to skin... is this possible?

Post by Yincognito »

RogerDingo wrote: February 7th, 2020, 12:12 pmim thinking maybe a IF THEN statement might be the way to go...
very basic thinking....

Code: Select all

IF disk 1 detected
then 
create meter for disk 1

IF disk 2 detected
then 
create meter for disk 2

IF disk 3 detected
then 
create meter for disk 3
something along those lines...
I don't know about getting the number of disks in a network (maybe others will know more about this), just wanted to say that Rainmeter doesn't work as a programming language (with if...then...else statements). What it has is a very limited set of test conditions, and hence...
RogerDingo wrote: February 7th, 2020, 12:12 pmif the disk is removed the 3rd meter still reports the disk but as 0
That's perfectly fine, because now you'll be able to hide the meter (can't just wipe it out of existence) if the associated measure's value is 0, through either an IfCondition option (if you test the measure returning 0 after its number value) or an IfMatch option (if you test the measure returning "0" after its string value).

In other words, instead of removing the meters corresponding to "invalid"/inexistent disks, you can hide them or, say, color them differently if the number/string value of the measure used to get that disk returns 0.

References:
IfConditions
IfMatchActions
Meter "bangs" (!HideMeter "SomeMeter" can be used to hide a meter)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
RogerDingo
Posts: 14
Joined: February 6th, 2020, 4:11 pm

Re: autodetecting disks - if disk exist then add to skin... is this possible?

Post by RogerDingo »

thanks for the info... yep understood that its not a programming language

i think the hide option would be good ....

the reason why id need to remove/hide the meters not in use is because not every server is the same
some servers have 10 disks others have 2 and some have 4

im trying to minimise the amount of 'noise' on screen by not showing the meters that arent being used.
so yes.. hiding them would be fine

ill check the references you linked and see if i can work it out.


thanks!
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: autodetecting disks - if disk exist then add to skin... is this possible?

Post by Yincognito »

RogerDingo wrote: February 7th, 2020, 12:53 pmill check the references you linked and see if i can work it out. thanks!
A little help (this does pretty much what you want on a basic level, but for local disks - it's up to you to adapt it for network ones):

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

---Measures---

[MeasureTotalDiskSpace1]
Measure=FreeDiskSpace
Drive=C:
Total=1
UpdateDivider=5
IfCondition=MeasureTotalDiskSpace1=0
IfTrueAction=[!HideMeter MeterDriveInfo1]

[MeasureTotalDiskSpace2]
Measure=FreeDiskSpace
Drive=D:
Total=1
UpdateDivider=5
IfCondition=MeasureTotalDiskSpace2=0
IfTrueAction=[!HideMeter MeterDriveInfo2]

[MeasureTotalDiskSpace3]
Measure=FreeDiskSpace
Drive=E:
Total=1
UpdateDivider=5
IfCondition=MeasureTotalDiskSpace3=0
IfTrueAction=[!HideMeter MeterDriveInfo3]

---Meters---

[MeterDriveInfo1]
Meter=String
MeasureName=MeasureTotalDiskSpace1
X=0
Y=0R
FontSize=10
FontColor=255,255,255,255
SolidColor=0,0,0,255
AntiAlias=1
AutoScale=1
Text="Drive 1: [Total: %1B]"

[MeterDriveInfo2]
Meter=String
MeasureName=MeasureTotalDiskSpace2
X=0
Y=0R
FontSize=10
FontColor=255,255,255,255
SolidColor=0,0,0,255
AntiAlias=1
AutoScale=1
Text="Drive 2: [Total: %1B]"

[MeterDriveInfo3]
Meter=String
MeasureName=MeasureTotalDiskSpace3
X=0
Y=0R
FontSize=10
FontColor=255,255,255,255
SolidColor=0,0,0,255
AntiAlias=1
AutoScale=1
Text="Drive 3: [Total: %1B]"
As you can see, assuming C, D, E exist as local drives, all 3 meters will be shown. However, if you set Drive=X: (assuming the X: drive doesn't exist) in [MeasureTotalDiskSpace3], then only the first 2 meters (of drives that do exist) will be shown.

P.S. You can, of course, add IfConditionMode=1 to each measure, in order to execute the appropriate actions in IfTrueAction on every update of the measure.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
RogerDingo
Posts: 14
Joined: February 6th, 2020, 4:11 pm

Re: autodetecting disks - if disk exist then add to skin... is this possible?

Post by RogerDingo »

Yincognito wrote: February 7th, 2020, 1:17 pm A little help (this does pretty much what you want on a basic level, but for local disks - it's up to you to adapt it for network ones):

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

---Measures---

[MeasureTotalDiskSpace1]
Measure=FreeDiskSpace
Drive=C:
Total=1
UpdateDivider=5
IfCondition=MeasureTotalDiskSpace1=0
IfTrueAction=[!HideMeter MeterDriveInfo1]

[MeasureTotalDiskSpace2]
Measure=FreeDiskSpace
Drive=D:
Total=1
UpdateDivider=5
IfCondition=MeasureTotalDiskSpace2=0
IfTrueAction=[!HideMeter MeterDriveInfo2]

[MeasureTotalDiskSpace3]
Measure=FreeDiskSpace
Drive=E:
Total=1
UpdateDivider=5
IfCondition=MeasureTotalDiskSpace3=0
IfTrueAction=[!HideMeter MeterDriveInfo3]

---Meters---

[MeterDriveInfo1]
Meter=String
MeasureName=MeasureTotalDiskSpace1
X=0
Y=0R
FontSize=10
FontColor=255,255,255,255
SolidColor=0,0,0,255
AntiAlias=1
AutoScale=1
Text="Drive 1: [Total: %1B]"

[MeterDriveInfo2]
Meter=String
MeasureName=MeasureTotalDiskSpace2
X=0
Y=0R
FontSize=10
FontColor=255,255,255,255
SolidColor=0,0,0,255
AntiAlias=1
AutoScale=1
Text="Drive 2: [Total: %1B]"

[MeterDriveInfo3]
Meter=String
MeasureName=MeasureTotalDiskSpace3
X=0
Y=0R
FontSize=10
FontColor=255,255,255,255
SolidColor=0,0,0,255
AntiAlias=1
AutoScale=1
Text="Drive 3: [Total: %1B]"
As you can see, assuming C, D, E exist as local drives, all 3 meters will be shown. However, if you set Drive=X: (assuming the X: drive doesn't exist) in [MeasureTotalDiskSpace3], then only the first 2 meters (of drives that do exist) will be shown.

P.S. You can, of course, add IfConditionMode=1 to each measure, in order to execute the appropriate actions in IfTrueAction on every update of the measure.
thats looking pretty good and it does remove one of the meters when i edit accordingly.
the disk skin has 3 meters to display c:/ disk usage and a bar below..

is there a way to hide multiple meters in one IfTrueAction ?
RogerDingo
Posts: 14
Joined: February 6th, 2020, 4:11 pm

Re: autodetecting disks - if disk exist then add to skin... is this possible?

Post by RogerDingo »

ok think i got it... need to do !hidemeter on each metername

IfTrueAction=[!HideMeter meterLabelDisk3][!HideMeter meterValueDisk3][!HideMeter meterBarDisk3]
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: autodetecting disks - if disk exist then add to skin... is this possible?

Post by Yincognito »

RogerDingo wrote: February 7th, 2020, 1:44 pm ok think i got it... need to do !hidemeter on each metername

IfTrueAction=[!HideMeter meterLabelDisk3][!HideMeter meterValueDisk3][!HideMeter meterBarDisk3]
Exactly - well done. Or, if you do that often on the same set of meters, you could add the desired meters to a group (see Group option) and then hide the entire group using a [!HideMeterGroup "Group Name Here"].
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
RogerDingo
Posts: 14
Joined: February 6th, 2020, 4:11 pm

Re: autodetecting disks - if disk exist then add to skin... is this possible?

Post by RogerDingo »

Yincognito wrote: February 7th, 2020, 2:18 pm Exactly - well done. Or, if you do that often on the same set of meters, you could add the desired meters to a group (see Group option) and then hide the entire group using a [!HideMeterGroup "Group Name Here"].
ah yep... that would make things a lot neater and reduce the amount of code needed to hide meters

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

Re: autodetecting disks - if disk exist then add to skin... is this possible?

Post by balala »

RogerDingo wrote: February 7th, 2020, 12:12 pm i added a 3rd disk to the server and the only way to add a new meter was to modify 2 Disk.ini and create a new ini file.. called...

3 Disk.ini

if the disk is removed the 3rd meter still reports the disk but as 0
RogerDingo wrote: February 7th, 2020, 1:44 pm ok think i got it... need to do !hidemeter on each metername

IfTrueAction=[!HideMeter meterLabelDisk3][!HideMeter meterValueDisk3][!HideMeter meterBarDisk3]
There seems to be a great confusion on Rainmeter terminology. According to the first quotation, you've created a new skin for the third disk, but according to the second one, only new meters have been created. The described method works in either case, just that in first case you have to hide the whole skin, while in second one, just the appropriate meters (or as Yincognito suggested the appropriate group of meters).
So in first case:

Code: Select all

[MeasureTotalDiskSpace1]
...
IfCondition=MeasureTotalDiskSpace1=0
IfTrueAction=[!HideFade]
IfFalseAction=[!ShowFade]
In second case on the other hand:

Code: Select all

[MeasureTotalDiskSpace1]
...
IfCondition=MeasureTotalDiskSpace1=0
IfTrueAction=[!HideMeter meterLabelDisk1][!HideMeter meterValueDisk1][!HideMeter meterBarDisk1]
IfFalseAction=[!ShowMeter meterLabelDisk1][!ShowMeter meterValueDisk1][!ShowMeter meterBarDisk1]
Which solution works, depends on how is (are) those skin(s) created. If you have a distinct skin for each disk, you have to use the first method, however if there is only one single skin, containing the meters for each disk, the second one is good for you.
Rereading the previous posts I believe the second case is alright, however I'm not entirely sure.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: autodetecting disks - if disk exist then add to skin... is this possible?

Post by balala »

Yincognito wrote: February 7th, 2020, 2:18 pm [!HideMeterGroup "Group Name Here"].
Just a side note, if permitted. Although it's not forbidden, neither a good idea is to use spaces into group names. It definitely will work even if you did, but you have to take extremely care to always include the name of the group into quotation, whenever are you using them, except the Group=Group Name Here definition of the group name on the appropriate meters. Whenever you want to show, hide, update or whatever the group, its name has to be included into quotations.
It's better to get used not to use spaces neither in group names, nor in meters or measures names, nor in variables names and so on. Much better approach, in my opinion.