I have the habit of quickly setting some reminders with:
sleep $duration; notify-send $reminder_message
But lately I have had to move around and often change desks. I noticed that my $reminder_message
started arriving later than intended. The culprit, it turn out is: that when I close lid then it suspends everything along with my sleep
command.
Here's how I found out:
date; echo $duration; date -d "+$duration sec"; sleep "$duration"s; date
If I close my lid in between the above command then: date
and date -d "+$duration sec"
don't match. However if lid is not closed then they match!
So for a quick-fix I have disabled suspend with lid-close with:
HandleLidSwitch=ignore
(following this ask-ubuntu answer)
Now my sleep commands work as I wanted them to. But disabling suspend altogether I feel is a too aggressive fix and an overkill!
Is there a simpler solution? I just want that my sleep
commands shouldn't be interrupted when I close my lid.
date; echo $duration; date -d "+$duration sec"; sleep "$duration"s; date
? Oh - this was just for testing. I wanted to verify the hypothesis if indeed sleep is interrupted if lid is closed. That is not my second attempt. – Inspired_Blue Sep 08 '22 at 07:26at
command at some point. But I can't recall now why I didn't like it. Let me see if I can recall and get back. If I can't I will accept your answer. – Inspired_Blue Sep 08 '22 at 07:29at
was that I can't doat +2 min 15 sec
. If I remember correctly, there is no support for handling duration in seconds inat
. Is that correct? Yes - that is correct: stackoverflow answer uses sleep with at for seconds – Inspired_Blue Sep 08 '22 at 07:50sudo
and using it withat
. But I am not sure if that was just me or if there was some genuine compatibility problem. – Inspired_Blue Sep 08 '22 at 07:57at
works perfectly fine! But there are other places where I have usedsleep
. I didn't knowsleep
had this feature/ bug. Now it worries me what else could be breaking. – Inspired_Blue Sep 08 '22 at 11:10at
doesn't support seconds? – Inspired_Blue Sep 08 '22 at 11:16