It is currently September 14th, 2024, 10:01 pm

Fortune-style config using QuotePlugin

Get help with creating, editing & fixing problems with skins
BWatkin
Posts: 4
Joined: September 19th, 2010, 7:57 pm

Fortune-style config using QuotePlugin

Post by BWatkin »

For anyone who may not know, "Fortune" is a program (on Linux and the like) which displays a random quote from a selection of files; art, law, philosophy, kids, riddles, etc...

I have downloaded the Fortune files, so I have a directory of files.

What I want the config to do;

1) Choose a random file
2) Pull a quote from that file
3) Display the quote (update every 5 min, 30 min, 24 hr, or whatever)

The code I've got so far is;

Code: Select all

[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=255,0,0,255
DynamicWindowSize=1

[MeasureFile]
Measure=Plugin
Plugin=Plugins\QuotePlugin.dll
PathName=F:\datfiles\
Subfolders=0

[MeterFile]
Meter=STRING
MeasureName=MeasureFile
FontColor=255,255,255,255

[MeasureFortune]
Measure=Plugin
Plugin=Plugins\QuotePlugin.dll
PathName=MeasureFile
Separator=%

[MeterFortune]
Meter=STRING
MeasureName=MeasureFortune
FontColor=255,255,255,255
Y=50
Anything to do with style or position is just so I can see the config and move it.
The extra Meter (MeterFile) is for my info and won't be in the final config.
Each quote is separated with a "%".
At the moment I have it updating every second, while I try to code it, but it'll be updating much less frequently once I'm done.

So far, it can get a random filename from the directory (e.g. "F:\datfiles\food.txt"), but I want to pass that filename to the "PathName" variable in the second Measure, using the QuotePlugin to pull a quote from that file. I don't know if it's actually not possible, or if I'm just doing it wrong, so any help in the right direction would be great!
User avatar
jsmorley
Developer
Posts: 22743
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Fortune-style config using QuotePlugin

Post by jsmorley »

Without testing myself since I don't have the source files, I suspect this will work:

[MeasureFortune]
Measure=Plugin
Plugin=Plugins\QuotePlugin.dll
PathName=[MeasureFile]
DynamicVariables=1
Separator=%

DO set some UpdateDivider=xxx settings on the quote plugin measures, so you are not thrashing your hard drive.
BWatkin
Posts: 4
Joined: September 19th, 2010, 7:57 pm

Re: Fortune-style config using QuotePlugin

Post by BWatkin »

Thanks for the swift reply!

I think you're right, but I just checked up on that section in the documentation and it says "There is also currently no support for Dynamic Variables in plugins, such as WebParser or QuotePlugin."

So, I can't do that...

I suppose I'll have to try a workaround of some sort.
User avatar
jsmorley
Developer
Posts: 22743
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Fortune-style config using QuotePlugin

Post by jsmorley »

BWatkin wrote:Thanks for the swift reply!

I think you're right, but I just checked up on that section in the documentation and it says "There is also currently no support for Dynamic Variables in plugins, such as WebParser or QuotePlugin."

So, I can't do that...

I suppose I'll have to try a workaround of some sort.
Oh, of course. Sorry, I wasn't thinking.

You should be able to use !RainmeterWriteKeyValue to set the filename. Use a calc with "counter" to execute every xxx seconds and have it use the value of the measure getting the file to set that in the measure getting the random line and refresh the skin.
BWatkin
Posts: 4
Joined: September 19th, 2010, 7:57 pm

Re: Fortune-style config using QuotePlugin

Post by BWatkin »

That seems like it should work, but I'll have to do some more playing around.

I figured I'd have to do something like that, but it would be much easier/better if DynamicVariables was supported in [Variables] or with Plugins.

In any case, thanks for the help, and I'll keep trying it until I either get it to work, or get stuck. And I'll be back in the morning with some sort of result.
BWatkin
Posts: 4
Joined: September 19th, 2010, 7:57 pm

Re: Fortune-style config using QuotePlugin

Post by BWatkin »

I tried using the counter variable with a Calc measure, but I don't think I fully understand how it works.

Using the example in the Tips and Tricks section, I set it to change the PathName and then refresh, but refreshing the config resets the counter, I think, so once it refreshed, it got stuck in a loop.
I tried a few things to get it all working, but either the PathName was updating too often, or the Meter to show the quote was updating too often, or both were updating too often at the same time.

All in all, it does work in setting the PathName, but it just needs some more messing about with in order to get each part updating at the right time. But it's late and I'm tired, so it's possible that I've overlooked something. A fresh start in the morning might help.

So far, though, I've just made it to refresh every 24 hours, or it can be clicked in order to change the quote.

Code: Select all

[Rainmeter]
Update=86400000
DynamicWindowSize=1

[MeasureFile]
Measure=Plugin
Plugin=Plugins\QuotePlugin.dll
PathName=F:\datfiles\
Subfolders=1

[MeterFortune]
Meter=STRING
MeasureName=MeasureFortune
FontColor=255,255,255,255
Text=%1
LeftMouseUpAction=!Execute [!RainmeterWriteKeyValue MeasureFortune PathName [MeasureFile]] [!RainmeterRefresh]

[MeasureFortune]
Measure=Plugin
Plugin=Plugins\QuotePlugin.dll
Separator=%
PathName=F:\datfiles\off\limerick.txt
The final line is updated each time the config refreshes.

Also, I read somewhere else that the QuotePlugin has a character limit, so it won't read past a certain point if the quotes file is too long, but it should be easy enough to break the files into smaller chunks.