2020-05-27 13:20:08 +00:00
|
|
|
{ pkgs, ... }:
|
2018-05-26 20:48:33 +00:00
|
|
|
let
|
2020-05-27 13:20:08 +00:00
|
|
|
sleep-nag = pkgs.writeHaskellScript {
|
2019-10-19 23:25:58 +00:00
|
|
|
name = "sleep-nag";
|
|
|
|
imports = [
|
|
|
|
"Data.Time.LocalTime"
|
2019-10-20 04:35:10 +00:00
|
|
|
"Data.Time.Format"
|
|
|
|
"Data.Time.Clock"
|
2019-10-19 23:25:58 +00:00
|
|
|
"Control.Concurrent"
|
2019-10-20 03:28:54 +00:00
|
|
|
"Data.Functor"
|
2019-10-19 23:25:58 +00:00
|
|
|
];
|
2019-12-16 13:28:48 +00:00
|
|
|
bins = [ pkgs.libnotify ];
|
2019-10-19 23:25:58 +00:00
|
|
|
} ''
|
2019-10-20 04:35:10 +00:00
|
|
|
main = forever $ do
|
|
|
|
time <- getZonedTime
|
|
|
|
let tod = localTimeOfDay . zonedTimeToLocalTime$ time
|
|
|
|
hour = todHour tod
|
2020-10-12 22:17:38 +00:00
|
|
|
night = (hour < 6 && hour >= 1)
|
|
|
|
if night then do {
|
|
|
|
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}
|
2019-10-20 04:35:10 +00:00
|
|
|
else
|
2020-10-12 22:17:38 +00:00
|
|
|
threadDelay 600000000
|
2019-07-31 21:56:52 +00:00
|
|
|
'';
|
2018-05-26 20:48:33 +00:00
|
|
|
in {
|
2018-05-31 10:34:48 +00:00
|
|
|
|
2018-05-26 20:48:33 +00:00
|
|
|
systemd.user = {
|
|
|
|
services.sleep-nag = {
|
2019-07-31 21:56:52 +00:00
|
|
|
Unit = { Description = "Sleep nag"; };
|
2019-10-19 23:25:58 +00:00
|
|
|
Service = { ExecStart = "${sleep-nag}/bin/sleep-nag"; };
|
2019-07-31 21:56:52 +00:00
|
|
|
Install = { WantedBy = [ "graphical-session.target" ]; };
|
2018-05-26 20:48:33 +00:00
|
|
|
};
|
|
|
|
};
|
2018-05-31 10:34:48 +00:00
|
|
|
|
2018-05-26 20:48:33 +00:00
|
|
|
}
|