Been getting nowhere with editing this MinimalTimer config for hours on my own so I thought its time to ask for help. I've tried pilfering bits of code from various places and tacking it on to no avail. I've broken it more times than I can count!
I just want Stopwatch Text/MeterCenterText to show time left in minutes, rather than seconds as it is at the moment. If possible, seconds would also show in addition to minutes but in a smaller font. Then once there is less than a minute left, it would show just seconds again.
I have a feeling I'm looking at the right parameters with MeasureTimerScript and MeasureMinutesRemaining but I simply can't fathom how to bring it together. Edit: .. Maybe I should be looking somewhere in this lua script and adding a formula to divide seconds by 60?
image_2022-05-09_131738767.png
A secondary objective would be to automatically start timer sessions in a regimented way - i.e a work day with consistent breaks. Perhaps that might be too complicated?
function Initialize()
-- Get variables from external state
TimerEndOfTimer=tonumber(SKIN:GetVariable('TimerEndOfTimer', '0'))
FlashTimeoutSeconds=tonumber(SKIN:GetVariable('FlashTimeoutSeconds', '30'))
TimeMeasure=SKIN:GetMeasure('MeasureTime')
TimeOffset=0 -- represents the offset between os.clock() and Rainmeter time
Flashing=0
end
function Update()
if TimeOffset == 0 then
TimeOffset=TimeMeasure:GetValue() - os.clock()
end
CurrentTime = os.clock() + TimeOffset
returnVal = -1
if TimerEndOfTimer == 0 then
if Flashing > 0 and Flashing <= CurrentTime then
Flashing = 0
SKIN:Bang('!SetVariable', 'Flashing', Flashing)
end
elseif TimerEndOfTimer > CurrentTime then
returnVal = TimerEndOfTimer - CurrentTime
else
EndTimer()
end
return returnVal
end
function EndTimer()
TimerEndOfTimer = 0
SetVariable('TimerEndOfTimer', TimerEndOfTimer)
SetVariable('TimerCount', '(#TimerCount#+#ActiveTimerCount#)')
if tonumber(SKIN:GetVariable('AlarmAtEnd', '0')) == 1 then
SKIN:Bang('!CommandMeasure', 'MeasureAhkWindowMessaging', 'SendMessage 16687 1 0')
SKIN:Bang('!execute [Play Alarm.Wav]')
Flashing = FlashTimeoutSeconds + TimeMeasure:GetValue()
SKIN:Bang('!SetVariable', 'Flashing', Flashing)
end
end
function StartTimerAPI(duration, color, active)
StartTimerHelper(duration, color, active, 0)
end
function StartTimer(duration, color, active)
StartTimerHelper(duration, color, active, 1)
SKIN:Bang('!CommandMeasure', 'MeasureAhkWindowMessaging', 'SendMessage 16687 0 ' .. duration * 60)
end
function StartTimerHelper(duration, color, active, alarmatend)
duration = tonumber(duration or 0)
Flashing = 0
SKIN:Bang('!SetVariable', 'Flashing', Flashing)
if duration <= 0 then
TimerEndOfTimer = 0
else
TimerEndOfTimer = duration * 60 + TimeMeasure:GetValue()
end
SetVariable('TimerEndOfTimer', TimerEndOfTimer)
SetVariable('ColorTimerArc', color)
SetVariable('ActiveTimerCount', active or 0)
SetVariable('AlarmAtEnd', alarmatend)
-- riffing on https://www.cs.hmc.edu/~geoff/classes/hmc.cs070.200101/homework10/hashfuncs.html
SetVariable('EndOfTimerHash', ((1+SKIN:GetVariable('EndOfTimerHash', '1'))*TimeMeasure:GetValue()*0.5*(math.sqrt(5)-1)) % 1)
SKIN:Bang('!UpdateMeasure', 'MeasureTimerScript')
SKIN:Bang('!Update')
end
function SetVariable(variablename, value)
if value == nil then
value = '#' .. variablename .. '#'
else
SKIN:Bang('!SetVariable', variablename, value)
end
SKIN:Bang('!WriteKeyValue', 'Variables', variablename, value, '#@#state.inc')
end
Rainmeter 4.5.13.3632 (64-bit)
Language: English (1033)
Build time: 2022-03-23 15:23:40
Windows 10 Home 2009 64-bit (build 19043) - English (2057)
Path: C:\Program Files\Rainmeter\
SkinPath: C:\Users\khome\Documents\Rainmeter\Skins\
SettingsPath: C:\Users\khome\AppData\Roaming\Rainmeter\
IniFile: C:\Users\khome\AppData\Roaming\Rainmeter\Rainmeter.ini
Thank you for any assistance rendered!
You do not have the required permissions to view the files attached to this post.
Awesome thanks! Of course not expecting a solution to be given immediately, on the contrary I'm very grateful for any help or direction at all.
I did actually come across your timer but discarded it as it didn't have the aesthetic I was looking for (probably put too much value on this to be fair). Now that I've looked at it properly, the functionality looks very good indeed! I'll have a go.