1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +01:00

swaynag: add module

Swaynag is a replacement of i3-nag for sway. Swaynag is embedded in
Sway's build process albeit it is not an integral part of Sway,
therefore it has been added under `wayland.windowManager.sway` instead
of `programs`. It can be moved at a later time if necessary.

Two unit tests were added validate the module behavior for an empty
configuration and the example configuration.
This commit is contained in:
polykernel 2021-11-20 23:06:12 -05:00 committed by Robert Helgesson
parent 1abd311eef
commit 15ae861e1b
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
8 changed files with 138 additions and 0 deletions

2
.github/CODEOWNERS vendored
View file

@ -353,6 +353,8 @@
/modules/services/window-managers/i3-sway/sway.nix @alexarice @sumnerevans /modules/services/window-managers/i3-sway/sway.nix @alexarice @sumnerevans
/tests/modules/services/window-managers/sway @sumnerevans /tests/modules/services/window-managers/sway @sumnerevans
/modules/services/window-managers/i3-sway/swaynag.nix @polykernel
/modules/services/wlsunset.nix @matrss /modules/services/wlsunset.nix @matrss
/tests/modules/services/wlsunset @matrss /tests/modules/services/wlsunset @matrss

View file

@ -2233,6 +2233,14 @@ in
A new module is available: 'programs.hexchat'. A new module is available: 'programs.hexchat'.
''; '';
} }
{
time = "2021-11-21T17:21:04+00:00";
condition = config.wayland.windowManager.sway.enable;
message = ''
A new module is available: 'wayland.windowManager.sway.swaynag'.
'';
}
]; ];
}; };
} }

View file

@ -227,6 +227,7 @@ let
./services/window-managers/bspwm/default.nix ./services/window-managers/bspwm/default.nix
./services/window-managers/i3-sway/i3.nix ./services/window-managers/i3-sway/i3.nix
./services/window-managers/i3-sway/sway.nix ./services/window-managers/i3-sway/sway.nix
./services/window-managers/i3-sway/swaynag.nix
./services/window-managers/xmonad.nix ./services/window-managers/xmonad.nix
./services/wlsunset.nix ./services/wlsunset.nix
./services/xcape.nix ./services/xcape.nix

View file

@ -0,0 +1,70 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.wayland.windowManager.sway.swaynag;
iniFormat = pkgs.formats.ini { };
confFormat = with types;
let
confAtom = nullOr (oneOf [ bool int float str ]) // {
description = "Swaynag config atom (null, bool, int, float, str)";
};
in attrsOf confAtom;
in {
meta.maintainers = with maintainers; [ polykernel ];
options = {
wayland.windowManager.sway.swaynag = {
enable = mkEnableOption
"configuration of swaynag, a lightweight error bar for sway";
settings = mkOption {
type = types.attrsOf confFormat;
default = { };
description = ''
Configuration written to
<filename>$XDG_CONFIG_HOME/swaynag/config</filename>.
</para><para>
See
<citerefentry>
<refentrytitle>swaynag</refentrytitle>
<manvolnum>5</manvolnum>
</citerefentry>
for a list of avaliable options and an example configuration.
Note, configurations declared under <literal>&lt;config&gt;</literal>
will override the default type values of swaynag.
'';
example = literalExpression ''
{
"<config>" = {
edge = "bottom";
font = "Dina 12";
};
green = {
edge = "top";
background = "00AA00";
text = "FFFFFF";
button-background = "00CC00";
message-padding = 10;
};
}
'';
};
};
};
config = mkIf cfg.enable {
assertions = [
(hm.assertions.assertPlatform "wayland.windowManager.sway.swaynag" pkgs
platforms.linux)
];
xdg.configFile."swaynag/config" = mkIf (cfg.settings != { }) {
source = iniFormat.generate "swaynag.conf" cfg.settings;
};
};
}

View file

@ -10,4 +10,6 @@
sway-post-2003 = ./sway-post-2003.nix; sway-post-2003 = ./sway-post-2003.nix;
sway-workspace-default = ./sway-workspace-default.nix; sway-workspace-default = ./sway-workspace-default.nix;
sway-workspace-output = ./sway-workspace-output.nix; sway-workspace-output = ./sway-workspace-output.nix;
swaynag-example-settings = ./swaynag-example-settings.nix;
swaynag-empty-settings = ./swaynag-empty-settings.nix;
} }

View file

@ -0,0 +1,15 @@
{ config, lib, pkgs, ... }:
{
config = {
wayland.windowManager.sway.swaynag = {
enable = true;
settings = { };
};
nmt.script = ''
assertPathNotExists home-files/.config/swaynag
'';
};
}

View file

@ -0,0 +1,10 @@
[<config>]
edge=bottom
font=Dina 12
[green]
background=00AA00
button-background=00CC00
edge=top
message-padding=10
text=FFFFFF

View file

@ -0,0 +1,30 @@
{ config, lib, pkgs, ... }:
{
config = {
wayland.windowManager.sway.swaynag = {
enable = true;
settings = {
"<config>" = {
edge = "bottom";
font = "Dina 12";
};
green = {
edge = "top";
background = "00AA00";
text = "FFFFFF";
button-background = "00CC00";
message-padding = 10;
};
};
};
nmt.script = ''
assertFileContent \
home-files/.config/swaynag/config \
${./swaynag-example-settings-expected.conf}
'';
};
}