mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
swaync: add module
Co-authored-by: Ryan Horiguchi <rhoriguchi@users.noreply.github.com>
This commit is contained in:
parent
0125041fc9
commit
5632659886
6 changed files with 163 additions and 0 deletions
|
@ -1549,6 +1549,18 @@ in {
|
|||
your physical disc (HDD/SSD).
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
time = "2024-04-29T22:01:51+00:00";
|
||||
condition = hostPlatform.isLinux;
|
||||
message = ''
|
||||
A new module is available: 'services.swaync'.
|
||||
|
||||
SwayNotificationCenter is a simple notification daemon with a GTK GUI
|
||||
for notifications and the control center. See
|
||||
https://github.com/ErikReider/SwayNotificationCenter for more.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -355,6 +355,7 @@ let
|
|||
./services/stalonetray.nix
|
||||
./services/status-notifier-watcher.nix
|
||||
./services/swayidle.nix
|
||||
./services/swaync.nix
|
||||
./services/swayosd.nix
|
||||
./services/sxhkd.nix
|
||||
./services/syncthing.nix
|
||||
|
|
113
modules/services/swaync.nix
Normal file
113
modules/services/swaync.nix
Normal file
|
@ -0,0 +1,113 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
|
||||
let
|
||||
|
||||
cfg = config.services.swaync;
|
||||
|
||||
jsonFormat = pkgs.formats.json { };
|
||||
|
||||
in {
|
||||
meta.maintainers = [ lib.hm.maintainers.abayomi185 ];
|
||||
|
||||
options.services.swaync = {
|
||||
enable = lib.mkEnableOption "Swaync notification daemon";
|
||||
|
||||
package = lib.mkPackageOption pkgs "swaynotificationcenter" { };
|
||||
|
||||
style = lib.mkOption {
|
||||
type = lib.types.nullOr (lib.types.either lib.types.path lib.types.lines);
|
||||
default = null;
|
||||
example = ''
|
||||
.notification-row {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.notification-row:focus,
|
||||
.notification-row:hover {
|
||||
background: @noti-bg-focus;
|
||||
}
|
||||
|
||||
.notification {
|
||||
border-radius: 12px;
|
||||
margin: 6px 12px;
|
||||
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.7),
|
||||
0 2px 6px 2px rgba(0, 0, 0, 0.3);
|
||||
padding: 0;
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
CSS style of the bar. See
|
||||
<https://github.com/ErikReider/SwayNotificationCenter/blob/main/src/style.css>
|
||||
for the documentation.
|
||||
|
||||
If the value is set to a path literal, then the path will be used as the CSS file.
|
||||
'';
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = jsonFormat.type;
|
||||
default = { };
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
positionX = "right";
|
||||
positionY = "top";
|
||||
layer = "overlay";
|
||||
control-center-layer = "top";
|
||||
layer-shell = true;
|
||||
cssPriority = "application";
|
||||
control-center-margin-top = 0;
|
||||
control-center-margin-bottom = 0;
|
||||
control-center-margin-right = 0;
|
||||
control-center-margin-left = 0;
|
||||
notification-2fa-action = true;
|
||||
notification-inline-replies = false;
|
||||
notification-icon-size = 64;
|
||||
notification-body-image-height = 100;
|
||||
notification-body-image-width = 200
|
||||
};
|
||||
'';
|
||||
description = ''
|
||||
Configuration written to {file}`$XDG_CONFIG_HOME/swaync/config.json`.
|
||||
See
|
||||
<https://github.com/ErikReider/SwayNotificationCenter/blob/main/src/configSchema.json>
|
||||
for the documentation.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
# at-spi2-core is to minimize journalctl noise of:
|
||||
# "AT-SPI: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files"
|
||||
home.packages = [ cfg.package pkgs.at-spi2-core ];
|
||||
|
||||
xdg.configFile = {
|
||||
"swaync/config.json".source =
|
||||
jsonFormat.generate "config.json" cfg.settings;
|
||||
"swaync/style.css" = lib.mkIf (cfg.style != null) {
|
||||
source = if lib.isStorePath cfg.style then
|
||||
cfg.style
|
||||
else
|
||||
pkgs.writeText "swaync/style.css" cfg.style;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.services.swaync = {
|
||||
Unit = {
|
||||
Description = "Swaync notification daemon";
|
||||
Documentation = "https://github.com/ErikReider/SwayNotificationCenter";
|
||||
PartOf = [ "graphical-session.target" ];
|
||||
After = [ "graphical-session-pre.target" ];
|
||||
ConditionEnvironment = "WAYLAND_DISPLAY";
|
||||
};
|
||||
|
||||
Service = {
|
||||
Type = "dbus";
|
||||
BusName = "org.freedesktop.Notifications";
|
||||
ExecStart = "${cfg.package}/bin/swaync";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
|
||||
Install.WantedBy = [ "graphical-session.target" ];
|
||||
};
|
||||
};
|
||||
}
|
|
@ -260,6 +260,7 @@ in import nmtSrc {
|
|||
./modules/services/screen-locker
|
||||
./modules/services/signaturepdf
|
||||
./modules/services/swayidle
|
||||
./modules/services/swaync
|
||||
./modules/services/swayosd
|
||||
./modules/services/sxhkd
|
||||
./modules/services/syncthing/linux
|
||||
|
|
1
tests/modules/services/swaync/default.nix
Normal file
1
tests/modules/services/swaync/default.nix
Normal file
|
@ -0,0 +1 @@
|
|||
{ swaync = ./swaync.nix; }
|
35
tests/modules/services/swaync/swaync.nix
Normal file
35
tests/modules/services/swaync/swaync.nix
Normal file
|
@ -0,0 +1,35 @@
|
|||
{ config, ... }:
|
||||
|
||||
{
|
||||
services.swaync = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage {
|
||||
name = "swaync";
|
||||
outPath = "@swaync@";
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent \
|
||||
home-files/.config/systemd/user/swaync.service \
|
||||
${
|
||||
builtins.toFile "swaync.service" ''
|
||||
[Install]
|
||||
WantedBy=graphical-session.target
|
||||
|
||||
[Service]
|
||||
BusName=org.freedesktop.Notifications
|
||||
ExecStart=@swaync@/bin/swaync
|
||||
Restart=on-failure
|
||||
Type=dbus
|
||||
|
||||
[Unit]
|
||||
After=graphical-session-pre.target
|
||||
ConditionEnvironment=WAYLAND_DISPLAY
|
||||
Description=Swaync notification daemon
|
||||
Documentation=https://github.com/ErikReider/SwayNotificationCenter
|
||||
PartOf=graphical-session.target
|
||||
''
|
||||
}
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue