1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-30 15:09:46 +01:00

khal: added options 'color' and 'priority'

This commit is contained in:
Johannes Rosenberger 2019-07-29 18:00:52 +02:00 committed by Robert Helgesson
parent 8e49f65f24
commit faabf67f93
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
2 changed files with 26 additions and 2 deletions

View file

@ -20,5 +20,26 @@ with lib;
type is set to discover. 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.
'';
};
}; };
} }

View file

@ -20,6 +20,10 @@ let
findSingle (a: a.primary) null null findSingle (a: a.primary) null null
(mapAttrsToList (n: v: v // {name= n;}) khalAccounts); (mapAttrsToList (n: v: v // {name= n;}) khalAccounts);
toKeyValueListIfDefined = attrs:
mapAttrsToList (n: v: "${n} = ${toString v}")
(filterAttrs (_: v: !isNull v) attrs);
genCalendarStr = name: value: genCalendarStr = name: value:
concatStringsSep "\n" ( concatStringsSep "\n" (
[ [
@ -27,7 +31,7 @@ let
"path = ${value.local.path + "/" + (optionalString (value.khal.type == "discover") value.khal.glob)}" "path = ${value.local.path + "/" + (optionalString (value.khal.type == "discover") value.khal.glob)}"
] ]
++ optional (value.khal.readOnly) "readonly = True" ++ optional (value.khal.readOnly) "readonly = True"
++ optional (!isNull value.khal.type) "type = ${value.khal.type}" ++ toKeyValueListIfDefined (getAttrs [ "type" "color" "priority" ] value.khal)
++ ["\n"] ++ ["\n"]
); );
@ -52,7 +56,6 @@ in
default = optionalAttrs (!isNull primaryAccount) { default = optionalAttrs (!isNull primaryAccount) {
default_calendar = if isNull primaryAccount.primaryCollection then primaryAccount.name else primaryAccount.primaryCollection; default_calendar = if isNull primaryAccount.primaryCollection then primaryAccount.name else primaryAccount.primaryCollection;
}; };
locale = { locale = {
timeformat = "%H:%M"; timeformat = "%H:%M";
dateformat = "%Y-%m-%d"; dateformat = "%Y-%m-%d";