Skip to content

Commit ef8b9f1

Browse files
committed
way-displays: support stateful configuration file
1 parent d23d20f commit ef8b9f1

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

modules/services/way-displays.nix

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
options,
23
config,
34
lib,
45
pkgs,
@@ -21,15 +22,18 @@ let
2122
yaml = pkgs.formats.yaml { };
2223
in
2324
{
24-
meta.maintainers = [ maintainers.jolars ];
25+
meta.maintainers = [
26+
maintainers.jolars
27+
maintainers.mightyiam
28+
];
2529

2630
options.services.way-displays = {
2731
enable = mkEnableOption "way-displays";
2832

2933
package = lib.mkPackageOption pkgs "way-displays" { };
3034

3135
settings = mkOption {
32-
type = yaml.type;
36+
type = types.nullOr yaml.type;
3337
default = { };
3438
example = literalExpression ''
3539
{
@@ -61,6 +65,9 @@ in
6165
{file}`$XDG_CONFIG_HOME/way-displays/cfg.yml`. See
6266
<https://github.com/alex-courtis/way-displays/wiki/Configuration> for a
6367
description of available options.
68+
69+
When `null` a configuration file is not generated,
70+
which allows way-displays to write its own configuration.
6471
'';
6572
};
6673

@@ -79,14 +86,20 @@ in
7986
(lib.hm.assertions.assertPlatform "services.way-displays" pkgs lib.platforms.linux)
8087
];
8188

82-
xdg.configFile."way-displays/cfg.yaml".source =
83-
yaml.generate "way-displays-config.yaml"
84-
(mergeSets [
85-
{
86-
CALLBACK_CMD = "${pkgs.libnotify}/bin/notify-send \"way-displays \${CALLBACK_LEVEL}\" \"\${CALLBACK_MSG}\"";
87-
}
88-
cfg.settings
89-
]);
89+
home.packages = [ cfg.package ];
90+
91+
wayland.windowManager = lib.mapAttrs (name: _: {
92+
systemd.variables = [ "XDG_VTNR" ];
93+
}) options.wayland.windowManager;
94+
95+
xdg.configFile."way-displays/cfg.yaml" = mkIf (cfg.settings != null) {
96+
source = yaml.generate "way-displays-config.yaml" (mergeSets [
97+
{
98+
CALLBACK_CMD = "${pkgs.libnotify}/bin/notify-send \"way-displays \${CALLBACK_LEVEL}\" \"\${CALLBACK_MSG}\"";
99+
}
100+
cfg.settings
101+
]);
102+
};
90103

91104
systemd.user.services.way-displays = {
92105
Unit = {

0 commit comments

Comments
 (0)