It is currently February 19th, 2020, 11:48 am

DriveList 2.0

Share and get help with Plugins and Addons
FlyingHyrax
Posts: 251
Joined: July 1st, 2011, 1:32 am
Location: US

DriveList 2.0

Post by FlyingHyrax »

DriveList is a simple plugin that detects which drive letters are mounted and allows you to access mounted drive letters by index. This allows for skins that display statistics for any number of connected drives without the user having to manually configure drive letters.

Plugin source, binaries, and instructions are all on GitHub:

(Historical post contents)
[Update 2014-06-28]
Currently working on a version that uses the parent/child measure model. Instead of a single plugin measure with a cycling list, the parent measure maintains the list and child measures return a drive letter from a specific index in the list. Having the looping, auto-sizing list was interesting, but personally I think this version might be more useful more of the time. I may be able to add the original behavior back in as a measure type or something, but for now it's stripped out for simplicity.

Readme here: https://github.com/FlyingHyrax/rm-drivelist-plugin/blob/multimeasure/README.markdown
Downloads here: https://github.com/FlyingHyrax/rm-drivelist-plugin/releases/tag/v2.0-beta1

The old plugin and sample skin can be downloaded on Github, but it will conflict with the new version. (Should probably rename the new one or something?)
[/Update]

[Update 2014-05-17]
Fixed (I think) a bug where the skin would not update correctly if the number of drives in the list went = 0 then > 0.
New release is here: 1.0.1

[Update 2014-01-10]
Thanks to poiru, brian, jsmorley, and cjthompson in the Rainmeter IRC channel, DriveList is now threaded and should not block/hang Rainmeter while finding drives. Oh, and it finds empty optical drives now.
I'm calling it a 1.0 release. :) Though perhaps I speak too soon...
The attached example skin has been updated with the new version of the plugin.
You can also get the plugin DLLs sans-example skin from GitHub.
A rough but potentially useful ReadMe file can be found here.

[Original]
This plugin detects mounted drives using the .NET System.IO.DriveInfo class, and keeps the names (drive letters) in a list. The plugin measure returns a drive letter from the list, and you can cycle through the list using !CommandMeasure bangs. So with DynamicVariables turned on, you can use [someDriveListPluginMeasure] as the value of the Drive key in a FreeDiskSpace measure, auto-detect all the drives connected to your computer, and switch between them without having to set a bunch of variables by hand.

This could probably be done by using this with this and a little of that, but I wanted the practice with C#, Visual Studio, and Git. And so practice I did. It's a bit niche, but at least it seems to work just fine.

So without further ado, here's a sample skin that includes the plugin. You shouldn't have to set a single drive-letter variable...
(No guarantees though. GPL merchantability and fitness for a particular purpose, etc. etc. ;) )
Last edited by FlyingHyrax on December 15th, 2014, 4:47 pm, edited 10 times in total.
Flying Hyrax on DeviantArt
User avatar
jsmorley
Developer
Posts: 20250
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: DriveList - auto-detect mounted drives

Post by jsmorley »

The only initial comment I would make it that it seems very "laggy" and "blocking" to me. It seems to take some time to search for and identify all drives on my system, (not that many really, I only end up with two that are not CD/DVD/Virtual drives or removed USB drives.) and while it is doing it Rainmeter seems to get pretty bogged down. Particularly if I have the skin loading with Rainmeter, the initial startup of Rainmeter is impacted and all my skins seem to take longer to load. Once that skin is fully loaded, then all is well.

I hate to say it, but I suspect we are looking at something that should probably be threaded, like Brian's FileView is.
FlyingHyrax
Posts: 251
Joined: July 1st, 2011, 1:32 am
Location: US

Re: DriveList - auto-detect mounted drives

Post by FlyingHyrax »

jsmorley wrote: I hate to say it, but I suspect we are looking at something that should probably be threaded, like Brian's FileView is.
Consarnit Jeff! You're undoubtedly right. I'm not running very many skins, don't have many drives, and my startup is already slow (for other reasons), so I don't think I ever would have noticed personally.

I did notice with debugging versions of the plugin (more log output) that it looked like GetString() was being called before Reload() and Update() were finished populating the list - I would catch index out-of-bounds exceptions for about the first two update cycles or so. (That's why I'm using an ErrorString option at the moment; so you can make the measure return a known valid value.)

I'm guessing that much of the lag is from the DriveInfo.GetDrives() call, and maybe in the Equals() comparing the two arrays of DriveInfo objects - which if true is unfortunate. I'm not sure how to solve that with threading. I need to check whether or not connected drives have changed somehow (to detect removable media). I think I can thread my updateListedDrives() method relatively easily, but I'm not sure how much that would help - it's very straightforward.

Perhaps just extract most of the current Update() method into it's own procedure and thread that? That should at least keep the plugin from blocking Rainmeter, right?

Thanks for the testing and feedback, I appreciate your help! :thumbup:
Last edited by FlyingHyrax on June 28th, 2014, 7:59 pm, edited 1 time in total.
Flying Hyrax on DeviantArt
User avatar
Aragas
Posts: 64
Joined: December 24th, 2012, 6:56 pm
Location: Russia, Moscow

Re: DriveList - auto-detect mounted drives

Post by Aragas »

jsmorley wrote:The only initial comment I would make it that it seems very "laggy" and "blocking" to me. It seems to take some time to search for and identify all drives on my system, (not that many really, I only end up with two that are not CD/DVD/Virtual drives or removed USB drives.) and while it is doing it Rainmeter seems to get pretty bogged down. Particularly if I have the skin loading with Rainmeter, the initial startup of Rainmeter is impacted and all my skins seem to take longer to load. Once that skin is fully loaded, then all is well.

I hate to say it, but I suspect we are looking at something that should probably be threaded, like Brian's FileView is.
I'm sorry to interfere, but what do you mean when you say "we are looking"? You want to rewrite C++ plugins to C#?
FlyingHyrax
Posts: 251
Joined: July 1st, 2011, 1:32 am
Location: US

Re: DriveList - auto-detect mounted drives

Post by FlyingHyrax »

Aragas wrote: I'm sorry to interfere, but what do you mean when you say "we are looking"? You want to rewrite C++ plugins to C#?
Oh no, he's just saying that this plugin needs to be threaded, so it doesn't block the main Rainmeter process while it's finding drives. :)
I'll work on it over the next few days.

Update:
I'm open to ideas on how to thread this thing - I tried just extracting most of the Update() method and threading that, but it seemed to make the return value unacceptably unpredictable. I also can't test for performance improvements; I couldn't get the original to stutter with pretty much everything I have mounted, including nine virtual optical drives... so I'm stumped. I might just try to rewrite it from scratch sometime instead of trying the impose threading on this version.
Flying Hyrax on DeviantArt
FlyingHyrax
Posts: 251
Joined: July 1st, 2011, 1:32 am
Location: US

Re: DriveList - auto-detect mounted drives

Post by FlyingHyrax »

First post updated with a rough-draft multi-threaded version of the plugin.
Binaries are debug versions so they produce quite a bit of log output.

[Update]
Multi-threading is (somewhat tentatively) complete; updated first post with new version of example skin.
Flying Hyrax on DeviantArt
anon456
Posts: 3
Joined: April 26th, 2014, 9:28 am

Re: [Updated] DriveList - auto-detect mounted drives

Post by anon456 »

Hello, I think it's a great plugin, keep up the good work :thumbup:

Though i have a problem: What i want is: USB pop up informer with multiple usb drive support. When i add auto pop up feature to my skin which contain DriveList plugin, it doesn't work how it suppose to. When i remove a usb drive, it is immediately deactivated, but when i plug in a usb drive it doesn't show up until i manually refresh. Code is like that:

Code: Select all

[Rainmeter]
Update=1000

[DriveList]
Measure=Plugin
Plugin=DriveList.dll
Fixed=0
Removable=1
Optical=0
Network=0
RAM=0
UpdateDivider=1
FinishAction=[!UpdateMeasureGroup "DriveMeasureGroup"][!UpdateMeter *]

--------------------------------------

[MeasureUSD]
Measure=FreeDiskSpace
Drive=[DriveList]
InvertMeasure=0
IgnoreRemovable=0
IfEqualValue=0
IfEqualAction=!execute [!RainmeterHideFade]
IfAboveValue=0
IfAboveAction=!execute [!RainmeterShowFade]
DynamicVariables=1
Group=DriveMeasureGroup
......
....
.

I added Group=DriveMeasureGroup and DynamicVariables=1 to all the necessary meter and measures. I tried auto pop feature in another skin and it worked perfectly. Is there anyway to solve this problem with playing around with this code or plugin options?
FlyingHyrax
Posts: 251
Joined: July 1st, 2011, 1:32 am
Location: US

Re: [Updated] DriveList - auto-detect mounted drives

Post by FlyingHyrax »

anon456 wrote: Though i have a problem...
Is there anyway to solve this problem with playing around with this code or plugin options?
Hi, sorry for the late reply. Haven't been on the forums in a while.
I tried your code and confirmed the problem. It's a bug in my plugin code. Haven't dug into it too deeply yet, but hopefully will be able to debug and fix this weekend.

[Update]
Should be fixed, you can download the new version here: 1.0.1
Thank you for finding the problem and letting me know. :thumbup:
Flying Hyrax on DeviantArt
User avatar
fred_gaou
Posts: 60
Joined: July 30th, 2014, 1:00 am

Re: DriveList Redux - now with parent/child measures!

Post by fred_gaou »

So useful. Thanks!
  • Rainmeter 4.2.0 beta r3104 64-bit (Jun 23 2018) - French (1036)
  • Windows 10 Pro 1607 64-bit (build 14393) - French (1036)
  • Path: D:\Programmes\Customisation\Rainmeter\
  • SkinPath: D:\Programmes\Customisation\Rainmeter\Skins\
  • SettingsPath: D:\Programmes\Customisation\Rainmeter\
  • IniFile: D:\Programmes\Customisation\Rainmeter\Rainmeter.ini
User avatar
fred_gaou
Posts: 60
Joined: July 30th, 2014, 1:00 am

Re: DriveList 2.0

Post by fred_gaou »

Hi, I don't know if it's a bug or if it's by designed but the count of drives returned by the parent measure is always 0 the first time the measure operate. It returns the actual number of drives only after the parent measure run again either after the updatedivider specified in the measure or by a manual bang such as

Code: Select all

LeftMouseUpAction=[!UpdateMeasure "parentMeasure"]
It doesn't seem logical to me. Could you explain this, please?
  • Rainmeter 4.2.0 beta r3104 64-bit (Jun 23 2018) - French (1036)
  • Windows 10 Pro 1607 64-bit (build 14393) - French (1036)
  • Path: D:\Programmes\Customisation\Rainmeter\
  • SkinPath: D:\Programmes\Customisation\Rainmeter\Skins\
  • SettingsPath: D:\Programmes\Customisation\Rainmeter\
  • IniFile: D:\Programmes\Customisation\Rainmeter\Rainmeter.ini