You can use the FileView plugin to count the number of files in your Unsplash folder and use a Calc measure to add 1 to that value. That way the filename will always be 1 above the number of images you have saved. The downside is if you
manually delete one of those images, and do not rename them all in sequence, you will have gaps in the names AND the next saved download will overwrite previous images with names having numbers higher than the number of images counted by the plugin.
Here is your code modified to use the Fileview plugin to monitor the saved images and control the
Count. I set the value of
Count to the Fileview child measure [MeasureFileCount], but I do not use the
Count variable, instead when saving the image, the measure value is used; It will save the current download as the next image number based on the value of [MeasureCount]
I saved this as 'UnplashForRainmeterMine - 03.ini, so I could refer back to your version (- 02).
Code: Select all
[Rainmeter]
Update=1000
Group=Switch
AccurateText=1
BackgroundMode=2
SolidColor=0,0,0,1
DynamicWindowSize=1
ContextTitle=Setting
ContextAction=[!ActivateConfig "UnsplashForRainmeter\Setting"]
MouseScrollUpAction=[!SetVariable Scale "(#Scale#+#ScrollMouseIncrement#)"][!WriteKeyValue Variables Scale "(#Scale#+#ScrollMouseIncrement#)"][!Refresh]
MouseScrollDownAction=[!SetVariable Scale "(#Scale#-#ScrollMouseIncrement# < 0.2 ? 0.2 : #Scale#-#ScrollMouseIncrement#)"][!WriteKeyValue Variables Scale "(#Scale#-#ScrollMouseIncrement# < 0.2 ? 0.2 : #Scale#-#ScrollMouseIncrement#)"][!Refresh]
[Metadata]
Name=Unsplash
Author=XukaKun (khanhas@reddit, khanhas#3928@discord)
Information=Download and set wallpapers from famous Unsplash photo library automatically.
Version=1.0
License=Creative Commons Attribution - Non - Commercial - Share Alike 3.0
[Variables]
Scale=0.9
ScrollMouseIncrement=0.05
Start=0
Count=[MeasureFileCount]
Path=Unsplash/
Alpha1=0
Alpha2=0
Speed=5
Action=[!UpdateMeasure MeasureFader][!UpdateMeter *][!Redraw]
; ----------------------------------------- Fade
[MeasureFader]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat FadeIn1,#Speed#,20
FadeIn1=[!SetVariable Alpha1 "(Clamp(#Alpha1#+15,0,255))"]#Action#
ActionList2=Repeat FadeOut1,#Speed#,20
FadeOut1=[!SetVariable Alpha1 "(Clamp(#Alpha1#-15,0,255))"]#Action#
ActionList3=Repeat FadeIn2,#Speed#,20
FadeIn2=[!SetVariable Alpha2 "(Clamp(#Alpha2#+5,0,255))"]#Action#
ActionList4=Repeat FadeOut2,#Speed#,20
FadeOut2=[!SetVariable Alpha2 "(Clamp(#Alpha2#-5,0,255))"]#Action#
DynamicVariables=1
[MeasureStart]
Measure=Calc
Formula=#Start#
IfCondition=(#Start#=1)
IfTrueAction=[!WriteKeyValue Variables Start "0"][!DisableMeasure "#CURRENTSECTION#"]
UpdateDivider=-1
[MeasureFileViewParent]
Measure=Plugin
Plugin=FileView
Path=#CurrentPath#Unsplash\
UpdateDivider=5
DynamicVariables=1
[MeasureFileCount]
Measure=Plugin
Plugin=FileView
Path=[MeasureFileViewParent]
Type=FileCount
[MeasureCount]
Measure=Calc
Formula=MeasureFileCount + 1
RegExpSubstitute=1
Substitute="^(.)$":"0\1"
[MeasureRun]
Measure=Plugin
Plugin=RunCommand
Parameter=Copy "[Webparser]" "#Path#\Unsplash[MeasureCount].jpg"
State=Hide
DynamicVariables=1
[WebParser]
Measure=Plugin
Plugin=WebParser
URL=https://source.unsplash.com/random/#SCREENAREAWIDTH#x#SCREENAREAHEIGHT#/
UpdateRate=-1
Download=1
DownloadFile=Unsplash.jpg
FinishAction=[!SetOption Webparser FinishAction """[!SetWallpaper "DownloadFile\Unsplash.jpg"]"""]
[Background]
Meter=Shape
Shape=Rectangle 0,0,(160*#Scale#),(45*#Scale#),(10*#Scale#) | StrokeWidth 1 | StrokeColor 255,255,255,0 | Fill LinearGradient Gradient
Gradient=180 | 255,255,255,0 ; 0.1 | 255,255,255,#Alpha2# ; 1
MouseOverAction=[!CommandMeasure MeasureFader "Stop 2"][!CommandMeasure MeasureFader "Execute 1"][!CommandMeasure MeasureFader "Stop 4"][!CommandMeasure MeasureFader "Execute 3"]
MouseLeaveAction=[!CommandMeasure MeasureFader "Stop 1"][!CommandMeasure MeasureFader "Execute 2"][!CommandMeasure MeasureFader "Stop 3"][!CommandMeasure MeasureFader "Execute 4"]
MiddleMouseDownAction=["#SKINSPATH#\UnsplashForRainmeter\Unsplash"]
;MiddleMouseDownAction=["#Path#"]
MouseActionCursor=0
DynamicVariables=1
[Unsplash]
Meter=String
Text=UnSplash
FontFace=Gilroy ExtraBold
;Quicksand
;Gilroy ExtraBold
;HelveticaNeueLT Com 75 Bd
FontSize=(14*#Scale#)
X=(15*#Scale#)
Y=(23*#Scale#)
StringStyle=Normal
StringAlign=LeftCenter
AntiAlias=1
FontColor=255,255,255,#Alpha1#
LeftMouseUpAction=[!CommandMeasure WebParser Update][PLAY #@#Sounds\Elevator Ding.wav][!Redraw]
DynamicVariables=1
[Next]
Meter=Image
ImageName=#@#Images/Next.png
ImageRotate=90
X=(30*#Scale#)R
Y=(13*#Scale#)
W=(20*#Scale#)
LeftMouseUpAction=[!CommandMeasure "MeasureRun" "Run"][!CommandMeasure MeasureFileViewParent "Update"][PLAY #@#Sounds\Elevator Ding.wav]
DynamicVariables=1