Let me explain the situation:
Every time I wake up, I shower, start up my PC, go make coffee and sit down at the physical desktop. I then manually double-click a shortcut to a .bat file on the virtual desktop, which starts up my “life loop”. (I don’t start it automatically because it first has to connect to the VPN and it gets generally messy for complicated reasons.)
The “life loop” is basically a “while (1) { … }” script which performs all kinds of “jobs” all day. Before the loop, it runs the following code:
"Is it less than 10 minutes since the computer was booted?" "Have we not registered the last wake time within the last 20 hours?"
If both of these conditions are met, my script then registers the approximate “last wake time” as “the current time minus 30 minutes” (in order to account for the time it takes me to get up from the bed, shower, turn on the PC, etc.).
Normally, and for the longest time, this works perfectly. However, as I have been fearing, today, it did not register, because it had apparently been less than 20 hours (or is it more?) since the last time it registered this.
This may be dead simple to all of you, but I’ve actually been thinking about this and fine-tuning it for a long time now. However, it seems like it will never be perfect, even though I try to have a pretty rigid “sleep/wake scheme”. It seems like no matter what number of hours I choose for the second condition, it will never match for every day. It’s either too long or too short.
An obvious solution would of course be to have a separate shortcut called “start life loop and I have just woken up”, to manually tell it that yes, this is definitely when I’ve waken up. However, this doesn’t seem “clean” and it bothers me that I would have to have two separate shortcuts to start my “life loop”. It doesn’t seem as beautiful as simply running a single shortcut (or even starting it automatically on boot, which I’ll likely want sooner or later).
Also, it often happens that I’m forced to reboot the computer (or shut it down and later turn it on again) during the day, without me having any intention to go to bed/sleep. It also happens oftentimes that I have to kill the life loop temporarily without restarting the machine, for debugging and testing purposes. For this reason, I can’t just always register the “wake time” whenever I start the life loop.
It feels like there is some obvious solution to this which I just haven’t thought of, but I sure can’t figure it out. Maybe the only sane way is to have a separate shortcut for when I really have woken up, and this just cannot be reliably determined by the script’s logic?
PS: Maybe I should clarify that I have no hardware in my bed which would be able to determine when I really wake up by analyzing my brain waves or something crazy like that.