home-manager/gui: Add spotifyd, swaync
This commit is contained in:
103
home-manager/modules/swaync.nix
Normal file
103
home-manager/modules/swaync.nix
Normal file
@@ -0,0 +1,103 @@
|
||||
{ lib, pkgs, config, ... }:
|
||||
let
|
||||
inherit (builtins) isPath;
|
||||
inherit (lib) mkIf isStorePath;
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
jsonFormat = pkgs.formats.json { };
|
||||
|
||||
swayncConfig = with lib.types; submodule {
|
||||
freeformType = jsonFormat.type;
|
||||
|
||||
options = {
|
||||
"$schema" = mkOption {
|
||||
type = str;
|
||||
default = "${cfg.package}/etc/xdg/configSchema.json";
|
||||
description = ''
|
||||
Path to schema for config.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
cfg = config.services.swaync;
|
||||
in
|
||||
{
|
||||
options.services.swaync = with lib.types; {
|
||||
enable = mkEnableOption "Sway Notification Center";
|
||||
package = mkOption {
|
||||
type = package;
|
||||
default = pkgs.swaynotificationcenter;
|
||||
defaultText = literalExpression "pkgs.swaynotificationcenter";
|
||||
description = ''
|
||||
swaync package to use. Set to <code>null</code> to use the default package.
|
||||
'';
|
||||
};
|
||||
|
||||
settings = mkOption {
|
||||
type = swayncConfig;
|
||||
default = { };
|
||||
description = ''
|
||||
Configuration for Sway Notification Center, see swaync(1) for details.
|
||||
'';
|
||||
};
|
||||
|
||||
style = mkOption {
|
||||
type = nullOr (either path str);
|
||||
default = null;
|
||||
description = ''
|
||||
CSS styling for Sway Notification Center. If set to a path literal, this will be used
|
||||
instead of writing the string to a file.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
configSource = jsonFormat.generate "swaync.json" cfg.settings;
|
||||
styleSource = if isPath cfg.style || isStorePath cfg.style then
|
||||
cfg.style
|
||||
else
|
||||
pkgs.writeText "swaync.css" cfg.style;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
xdg = {
|
||||
# swaync _really_ wants to pull the CSS from the system config dir
|
||||
systemDirs.config = [ "${cfg.package}/etc/xdg" ];
|
||||
|
||||
configFile = {
|
||||
"swaync/config.json" = mkIf (cfg.settings != { }) {
|
||||
source = configSource;
|
||||
onChange = ''
|
||||
${cfg.package}/bin/swaync-client --reload-config
|
||||
'';
|
||||
};
|
||||
"swaync/style.css" = mkIf (cfg.style != null) {
|
||||
source = styleSource;
|
||||
onChange = ''
|
||||
${cfg.package}/bin/swaync-client --reload-css
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.services.swaync = {
|
||||
Unit = {
|
||||
Description = "Swaync notification daemon";
|
||||
Documentation = "https://github.com/ErikReider/SwayNotificationCenter";
|
||||
PartOf = [ "graphical-session.target" ];
|
||||
After = [ "graphical-session.target" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
Type = "dbus";
|
||||
BusName = "org.freedesktop.Notifications";
|
||||
ExecStart = "${cfg.package}/bin/swaync";
|
||||
ExecReload = "${cfg.package}/bin/swaync-client --reload-config ; ${cfg.package}/bin/swaync-client --reload-css";
|
||||
};
|
||||
|
||||
Install.WantedBy = [ "graphical-session.target" ];
|
||||
};
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user