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.