SilverAzide wrote:OK, so after investing WAY too much time for a very tiny return, here is my cut at it using the inestimable jsmorley's template.
Well, if you are going to go all out, there is what I think is a simpler way...
UptimeDual_1.0.rmskin
1.jpg
UptimeDual.ini:
Code: Select all
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
OnRefreshAction=[!CommandMeasure MeasureUserLoginTime "Run"]
[MeasureCurrentTime]
Measure=Time
[MeasureUpTime]
Measure=UpTime
Format="%4!i!d %3!i!h %2!i!m"
[MeasureGetUserName]
Measure=Plugin
Plugin=SysInfo
SysInfoType=USER_NAME
UpdateDivider=-1
[MeasureUserLoginTime]
Measure=Plugin
Plugin=RunCommand
Parameter=quser "[MeasureGetUserName]"
State=Hide
OutputType=ANSI
DynamicVariables=1
RegExpSubstitute=1
FinishAction=[!EnableMeasure MeasureCheckQuser][!UpdateMeasure MeasureCheckQuser]
[MeasureCheckQuser]
Measure=Script
ScriptFile=UptimeDual.lua
Disabled=1
UpdateDivider=-1
IfCondition=MeasureCheckQuser = -1
IfTrueAction=[!DisableMeasureGroup UserTimes][!SetOption MeterUserLogin MeasureName "MeasureUpTime"]
IfFalseAction=[!EnableMeasureGroup UserTimes][!UpdateMeasureGroup UserTimes][!SetOption MeterUserLogin MeasureName "MesureParseSeconds"]
[MeasureUserFormat]
Measure=Time
Group=UserTimes
TimeStamp=[MeasureCheckQuser]
TimeStampFormat=%m/%d/%Y %I:%M %p
Format=%a, %b %d - %I:%M %p
DynamicVariables=1
Disabled=1
[MeasureUserDiff]
Measure=Time
Group=UserTimes
TimeStamp=([MeasureCurrentTime:timestamp] - [MeasureUserFormat:timestamp])
DynamicVariables=1
Disabled=1
[MesureParseSeconds]
Measure=UpTime
Group=UserTimes
SecondsValue=[MeasureUserDiff:timestamp]
Format="%4!i!d %3!i!h %2!i!m"
Disabled=1
DynamicVariables=1
[MeterUpTimeText]
Meter=String
X=0
Y=0
StringAlign=Left
FontSize=10
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
Text=System
[MeterUpTime]
MeasureName=MeasureUpTime
Meter=String
X=154
Y=0r
StringAlign=Right
FontSize=10
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
[MeterUserLoginText]
Meter=String
X=0
Y=2R
StringAlign=Left
FontSize=10
FontColor=255,255,255,255
SolidColor=0,0,0,1
StringCase=Proper
AntiAlias=1
DynamicVariables=1
Text=[MeasureGetUserName]
[MeterUserLogin]
Meter=String
MeasureName=MesureParseSeconds
X=154
Y=0r
StringAlign=Right
FontSize=10
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
UptimeDual.lua:
Code: Select all
function Initialize()
dofile(SKIN:GetVariable('@')..'DateLib\\date.lua')
measureQuser = SKIN:GetMeasure('MeasureUserLoginTime')
end
function Update()
rawString = measureQuser:GetStringValue()
dateString = string.match(rawString, '.*>.+Active[%s]*none[%s]*(.*)\n')
if dateString then
return(date(dateString):fmt('%m/%d/%Y %I:%M %p'))
else
return -1
end
end
So what I am doing...
In the skin:
Use RunCommand to get the results of quser.exe as before, but don't do any Substitute, just get the entire raw value.
When that is done, use FinishAction to execute the Lua script.
FinishAction=[!EnableMeasure MeasureCheckQuser][!UpdateMeasure MeasureCheckQuser]
In the Lua:
In Initialize() load the included date.lua library as a dofile()
Get the value of the RunCommand measure as a string.
Parse the string using string.match() to get the date and time at the end. The system locale, the format of this date and time,
DOESN'T MATTER. Trust me, the date.lua library will figure it out, and create a "date object".
If a valid date object is created, then return that to the skin, with formatting to turn it into a particular date and time format that we can react to in the skin.
return(date(dateString):fmt('%m/%d/%Y %I:%M %p'))
If a valid date object is not created, which would be the case if quser.exe is missing, then just return -1.
Back in the skin:
Use IfCondition to test for a numeric return of -1 on the Script measure.
IfCondition=MeasureCheckQuser = -1
If it is -1, then bail out and use the system Uptime.
If it is not -1 (which means it will be our formatted string) then do all the "difference from now" and all that as we did before and format the results using the Uptime formatting.
=================
As I said, the date.lua library is included with this .rmskin. Use that. There are other versions floating around on the web, but this is the one that works with our Rainmeter / Lua interface.
The documentation for date.lua is at:
http://tieske.github.io/date/
It is a VERY powerful date and time handler, and I highly recommend it.
On the other hand, just USE it, the documentation is pretty good. Don't even open data.lua in a text editor, it will send you running away screaming. You don't have to understand the library code, it's just a black box.
You do not have the required permissions to view the files attached to this post.