2021-05-18 14:33:28 +00:00
|
|
|
{ pkgs, ... }:
|
|
|
|
let
|
|
|
|
calendars = pkgs.privateValue [ ] "calendars";
|
2022-02-20 15:58:23 +00:00
|
|
|
plans = pkgs.privateValue
|
|
|
|
{
|
|
|
|
"workDay" = "pass";
|
|
|
|
"weekend" = "pass";
|
|
|
|
}
|
|
|
|
"plans";
|
|
|
|
planning = pkgs.writeShellScriptBin "planning" ''
|
|
|
|
create-plans; kassandra2
|
|
|
|
'';
|
|
|
|
ui = pkgs.writeShellScriptBin "calendar" ''
|
|
|
|
create-plans; ikhal -d Serien
|
|
|
|
'';
|
|
|
|
createPlans = pkgs.writeHaskellScript
|
|
|
|
{
|
|
|
|
name = "create-plans";
|
|
|
|
bins = [ pkgs.khal pkgs.vdirsyncer ];
|
|
|
|
imports = [
|
|
|
|
"Data.Time"
|
|
|
|
];
|
|
|
|
} ''
|
|
|
|
main = do
|
|
|
|
today <- localDay . zonedTimeToLocalTime <$> getZonedTime
|
|
|
|
[0..7] & fmap (`addDays` today) & mapM_ \day -> do
|
|
|
|
planned <- khal ["list", "-a", "Planung", show day, "06:00", "24h", "--notstarted"] |> captureTrim
|
|
|
|
when (planned == "No events") $ do
|
|
|
|
say $ "Creating events for " <> show day
|
|
|
|
if (dayOfWeek day `elem` [Saturday, Sunday]) then do
|
|
|
|
${plans.weekend}
|
|
|
|
else do
|
|
|
|
${plans.workDay}
|
|
|
|
'';
|
2021-04-12 13:41:05 +00:00
|
|
|
in
|
|
|
|
{
|
2022-02-20 15:58:23 +00:00
|
|
|
home.packages = [ pkgs.khal createPlans planning ui ];
|
2021-07-05 19:18:23 +00:00
|
|
|
xdg.configFile."khal/config".text = ''
|
2022-02-20 15:58:23 +00:00
|
|
|
[locale]
|
|
|
|
dateformat = "%Y-%m-%d"
|
|
|
|
datetimeformat = "%Y-%m-%d %H:%M"
|
|
|
|
timeformat = "%H:%M"
|
2021-02-14 20:19:25 +00:00
|
|
|
[default]
|
|
|
|
default_calendar = Standard
|
2020-12-21 01:37:55 +00:00
|
|
|
[calendars]
|
2021-07-05 19:18:23 +00:00
|
|
|
${pkgs.lib.concatMapStringsSep "\n" (
|
|
|
|
{ name, readOnly ? false, ... }: ''
|
2021-04-12 13:41:05 +00:00
|
|
|
[[${name}]]
|
|
|
|
type = discover
|
|
|
|
path = ~/.calendars/${name}/*
|
2021-07-05 19:18:23 +00:00
|
|
|
readonly = ${if readOnly then "True" else "False"}''
|
|
|
|
) calendars}
|
|
|
|
'';
|
2020-12-21 01:37:55 +00:00
|
|
|
}
|