I am trying to convert this EyeCare Chrome extension into an Electron app so that if you are not using the browser, this app can be installed on your machine and still reminds you to take care of your body and eyes every "N" minute.
The extension is able to open a new browser tab every "N" minute and the tab gets the focus.
I am trying to bring the Electron app to the foreground every "N" minute. I am storing the "N" value in a file and reading from it. N = User selected time (i.e. 10,20,30,40,50,60 min).
Is there a way I can make the Electron app foreground every "N" minute?
It would be great if the solution can be applied to all the platforms (Linux, Windows, and Mac).
Use win.focus();
to bring the window to the foreground.
To focus the window every "N" minutes use setInterval
like this:
var minsNum = 20; // Minutes in between each focus.
setInterval(function ()
{
win.focus();
}, minsNum * 60 * 1000); // setInterval uses milliseconds, so we're multiplying by 1000 to get it in seconds.