From faabf67f93aca2f71d043a510566a08c5812d651 Mon Sep 17 00:00:00 2001 From: Johannes Rosenberger Date: Mon, 29 Jul 2019 18:00:52 +0200 Subject: [PATCH] khal: added options 'color' and 'priority' --- modules/programs/khal-calendar-accounts.nix | 21 +++++++++++++++++++++ modules/programs/khal.nix | 7 +++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/modules/programs/khal-calendar-accounts.nix b/modules/programs/khal-calendar-accounts.nix index 12f1aeed2..f7f3dad61 100644 --- a/modules/programs/khal-calendar-accounts.nix +++ b/modules/programs/khal-calendar-accounts.nix @@ -20,5 +20,26 @@ with lib; type is set to discover. ''; }; + + color = mkOption { + type = types.nullOr (types.enum [ + "black" "white" "brown" "yellow" "dark gray" "dark green" "dark blue" + "light gray" "light green" "light blue" "dark magenta" "dark cyan" + "dark red" "light magenta" "light cyan" "light red" + ]); + default = null; + description = '' + Color in which events in this calendar are displayed. + ''; + example = "light green"; + }; + + priority = mkOption { + type = types.int; + default = 10; + description = '' + Priority of a calendar used for coloring. + ''; + }; }; } diff --git a/modules/programs/khal.nix b/modules/programs/khal.nix index 2e8c98310..f03e745ae 100644 --- a/modules/programs/khal.nix +++ b/modules/programs/khal.nix @@ -20,6 +20,10 @@ let findSingle (a: a.primary) null null (mapAttrsToList (n: v: v // {name= n;}) khalAccounts); + toKeyValueListIfDefined = attrs: + mapAttrsToList (n: v: "${n} = ${toString v}") + (filterAttrs (_: v: !isNull v) attrs); + genCalendarStr = name: value: concatStringsSep "\n" ( [ @@ -27,7 +31,7 @@ let "path = ${value.local.path + "/" + (optionalString (value.khal.type == "discover") value.khal.glob)}" ] ++ optional (value.khal.readOnly) "readonly = True" - ++ optional (!isNull value.khal.type) "type = ${value.khal.type}" + ++ toKeyValueListIfDefined (getAttrs [ "type" "color" "priority" ] value.khal) ++ ["\n"] ); @@ -52,7 +56,6 @@ in default = optionalAttrs (!isNull primaryAccount) { default_calendar = if isNull primaryAccount.primaryCollection then primaryAccount.name else primaryAccount.primaryCollection; }; - locale = { timeformat = "%H:%M"; dateformat = "%Y-%m-%d";