Search code examples
timeluarainmeter

How to run a Lua script at a certain hour mark?


I've altered one of the popular clock skins for Rainmeter to be exactly how I want it. However, the only issue is that the '1' in the clock for hours 10, 11, and 12 gets cut off by the edge of the skin with the current margins.

I know exactly which value needs to be altered at the given times, so all I need to figure out now is how to run a Lua script to change it when the clock hits them. Problem is, after much searching I don't have the slightest clue how. It definitely seems like something that should be easily possible.


Solution

  • You need to run your lua script as a cron job.

    In order to achieve this I'd suggest you use this cron.lua module which has the functionality you want. One example of what you can do is the following:

    local clock = cron.every(time, callback, ...). 
    --Creates a clock that will execute callback every time, periodically. Additional parameters are passed to the callback too.
    

    The callback variable is the code you want to be executed at every interval.