DigitalEssence wrote:Is there a way of reading in the newest file and getting Rainmeter/lua to check periodically if there is a newer file and if so, open and read that in instead?
Yeah, I think for such things, you could use the
FileView plugin, a lua script is not needed. Eg the following code will get the newest file of the specified folder, showing its name and details:
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
[Variables]
IconSize=Large
;----------------------------------------------------
; Styles
;----------------------------------------------------
[TextStyle]
FontColor=255,255,255,255
AntiAlias=1
[TextHighlight]
FontColor=150,150,255,255
[IconStyle]
X=5
Y=r
AntiAlias=1
[HighlightStyle]
SolidColor=0,0,0,1
X=5
Y=5R
W=380
H=([Index1Icon:H] > [Index1Info:H] ? [Index1Icon:H] : [Index1Info:H])
DynamicVariables=1
MouseOverAction=[!SetOption #CURRENTSECTION# SolidColor "50,50,255,150"][!UpdateMeter #CURRENTSECTION#][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# SolidColor ""][!UpdateMeter #CURRENTSECTION#][!Redraw]
[InfoStyle]
X=5R
Y=r
Text="%1 #CRLF#%2 #CRLF#%3 "
AutoScale=1
AntiAlias=1
;----------------------------------------------------
; Measures
;----------------------------------------------------
[mPath]
Measure=Plugin
Plugin=FileView
Path= ADD HERE THE NEEDED PATH
Count=1
SortType=Date
SortDateType=Created
SortAscending=0
ShowDotDot=0
[mFolderCount]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FolderCount
Group=Children
[mFileCount]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileCount
Group=Children
[mFolderSize]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FolderSize
Group=Children
;----------------------------------------------------
; Index 1
[mIndex1Name]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileName
Index=1
Group=Children
[mIndex1Size]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileSize
Index=1
Group=Children
[mIndex1Date]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=FileDate
DateType=Created
Index=1
Group=Children
[mIndex1Icon]
Measure=Plugin
Plugin=FileView
Path=[mPath]
Type=Icon
IconSize=#IconSize#
Index=1
Group=Children
;----------------------------------------------------
; Meters
;----------------------------------------------------
[Index1]
Meter=Image
MeterStyle=HighlightStyle
LeftMouseDoubleClickAction=[!CommandMeasure mIndex1Name "FollowPath"][!UpdateMeasure mPath][!UpdateMeasureGroup Children][!UpdateMeter *][!Redraw]
[Index1Icon]
Meter=Image
MeasureName=mIndex1Icon
MeterStyle=IconStyle
[Index1Info]
Meter=String
MeasureName=mIndex1Name
MeasureName2=mIndex1Size
MeasureName3=mIndex1Date
MeterStyle=TextStyle | InfoStyle
The most important options are the followings:
Code: Select all
[mPath]
...
Count=1
SortType=Date
SortDateType=Created
SortAscending=0
ShowDotDot=0
The SortType option ensures that the files will be sorted by date. The SortDateType ensures that the creation date will be used, not the access or modification date. The SortAscending option tells the plugin to sort the files descending (take care that the default option here is the ascending sorting, in which case the code will show not the newest, but the oldest file). Finally the ShowDotDot options will ensure that the parent folder isn't taken into account.
Now the
DateType=Created option of the [mIndex1Date] measure, tells this measure to show the creation date of the file, instead of any other date.
And finally, the
[mPath]\[mIndex1Name] expression will return the path and name of the newest file of folder. Use this expression onto the appropriate measure or into the lua script.