Skip to content

Commit

Permalink
wpaperd: add systemd service; move to services/ from programs/
Browse files Browse the repository at this point in the history
Re: #4538, wpaperd needs something to run it after being enabled. This commit adds a systemd service to run it, and accordingly moves it to services.wpaperd.

In addition, the existing tests have been migrated to services, and an entry in the newslist has been created alerting users to this change.
  • Loading branch information
3ulalia committed Jan 10, 2025
1 parent 2532b50 commit cfd54b9
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 52 deletions.
6 changes: 6 additions & 0 deletions modules/lib/maintainers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -634,4 +634,10 @@
github = "ALameLlama";
githubId = 55490546;
};
"3ulalia" = {
name = "Eulalia del Sol";
email = "[email protected]";
github = "3ulalia";
githubId = "179992797";
};
}
10 changes: 10 additions & 0 deletions modules/misc/news.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1960,6 +1960,16 @@ in {
as well as wf-shell.
'';
}
{
time = "2025-01-10T23:11:24+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.wpaperd'.
This replaces the existing module, 'programs.wpaperd', and adds a
systemd service to ensure its execution.
'';
}
];
};
}
2 changes: 1 addition & 1 deletion modules/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ let
./programs/wezterm.nix
./programs/wlogout.nix
./programs/wofi.nix
./programs/wpaperd.nix
./programs/xmobar.nix
./programs/xplr.nix
./programs/yambar.nix
Expand Down Expand Up @@ -411,6 +410,7 @@ let
./services/window-managers/xmonad.nix
./services/wlsunset.nix
./services/wob.nix
./services/wpaperd.nix
./services/xcape.nix
./services/xembed-sni-proxy.nix
./services/xidlehook.nix
Expand Down
49 changes: 0 additions & 49 deletions modules/programs/wpaperd.nix

This file was deleted.

84 changes: 84 additions & 0 deletions modules/services/wpaperd.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{ config, lib, pkgs, ... }:

let
cfg = config.services.wpaperd;
tomlFormat = pkgs.formats.toml { };
inherit (lib) mkRenamedOptionModule mkIf;
in {
meta.maintainers = [ lib.hm.maintainers."3ulalia" ];

imports = [
(mkRenamedOptionModule # \
[ "programs" "wpaperd" "enable" ] # \
[ "services" "wpaperd" "enable" ])
(mkRenamedOptionModule # \
[ "programs" "wpaperd" "package" ] # \
[ "services" "wpaperd" "package" ])
(mkRenamedOptionModule # \
[ "programs" "wpaperd" "settings" ] # \
[ "services" "wpaperd" "settings" ])
];

options.services.wpaperd = {
enable = lib.mkEnableOption "wpaperd";

package = lib.mkPackageOption pkgs "wpaperd" { };

settings = lib.mkOption {
type = tomlFormat.type;
default = { };
example = lib.literalExpression ''
{
eDP-1 = {
path = "/home/foo/Pictures/Wallpaper";
apply-shadow = true;
};
DP-2 = {
path = "/home/foo/Pictures/Anime";
sorting = "descending";
};
}
'';
description = ''
Configuration written to
{file}`$XDG_CONFIG_HOME/wpaperd/wallpaper.toml`.
See <https://github.com/danyspin97/wpaperd#wallpaper-configuration>
for the full list of options.
'';
};
};

config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.wpaperd" pkgs
lib.platforms.linux)
];

home.packages = [ cfg.package ];

xdg.configFile = {
"wpaperd/wallpaper.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "wpaperd-wallpaper" cfg.settings;
};
};

systemd.user.services.wpaperd = {
Install = { WantedBy = [ config.wayland.systemd.target ]; };

Unit = {
ConditionEnvironment = "WAYLAND_DISPLAY";
Description = "wpaperd";
PartOf = [ config.wayland.systemd.target ];
After = [ config.wayland.systemd.target ];
X-Restart-Triggers =
[ "${config.xdg.configFile."wpaperd/wallpaper.toml".source}" ];
};

Service = {
ExecStart = "${lib.getExe cfg.package}";
Restart = "always";
RestartSec = "10";
};
};
};
}
2 changes: 1 addition & 1 deletion tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ in import nmtSrc {
./modules/programs/waybar
./modules/programs/wlogout
./modules/programs/wofi
./modules/programs/wpaperd
./modules/programs/xmobar
./modules/programs/yambar
./modules/programs/yt-dlp
Expand Down Expand Up @@ -307,6 +306,7 @@ in import nmtSrc {
./modules/services/window-managers/wayfire
./modules/services/wlsunset
./modules/services/wob
./modules/services/wpaperd
./modules/services/xsettingsd
./modules/systemd
./modules/targets-linux
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{
config = {
programs.wpaperd = {
services.wpaperd = {
enable = true;
settings = {
eDP-1 = {
Expand Down

0 comments on commit cfd54b9

Please sign in to comment.