1
0
Fork 0

Update sleep-nag

This commit is contained in:
Malte Brandy 2020-10-13 00:17:38 +02:00
parent 5be4b11dbe
commit 99ad74c19d
No known key found for this signature in database
GPG key ID: 226A2D41EF5378C9

View file

@ -15,14 +15,12 @@ let
time <- getZonedTime time <- getZonedTime
let tod = localTimeOfDay . zonedTimeToLocalTime$ time let tod = localTimeOfDay . zonedTimeToLocalTime$ time
hour = todHour tod hour = todHour tod
night = (hour < 6 || hour >= 23) night = (hour < 6 && hour >= 1)
diff = diffUTCTime (zonedTimeToUTC time{zonedTimeToLocalTime = (zonedTimeToLocalTime time){localTimeOfDay = TimeOfDay 23 0 0}}) (zonedTimeToUTC time) if night then do {
delay = toRational diff notify_send ([i|Es ist #{formatTime defaultTimeLocale "%H:%M" time} Uhr: Zeit ins Bett zu gehen!|]::String) "Du kannst das hier auch morgen tun!";
if night then (do threadDelay 600000000}
notify_send ([i|Es ist #{formatTime defaultTimeLocale "%H:%M" time} Uhr: Zeit ins Bett zu gehen!|]::String) "Du kannst das hier auch morgen tun!"
threadDelay 600000000)
else else
threadDelay (floor $ delay * 1000000) threadDelay 600000000
''; '';
in { in {