aboutsummaryrefslogtreecommitdiff
path: root/share/hm-modules
diff options
context:
space:
mode:
Diffstat (limited to 'share/hm-modules')
-rw-r--r--share/hm-modules/wpaperd.nix74
1 files changed, 74 insertions, 0 deletions
diff --git a/share/hm-modules/wpaperd.nix b/share/hm-modules/wpaperd.nix
new file mode 100644
index 0000000..c38da21
--- /dev/null
+++ b/share/hm-modules/wpaperd.nix
@@ -0,0 +1,74 @@
+{ config, lib, pkgs, ... }:
+with lib;
+let
+ cfg = config.services.wpaperd;
+ tomlFormat = pkgs.formats.toml { };
+in
+{
+ options.services.wpaperd = {
+ enable = mkEnableOption "enable wpaperd";
+
+ package = mkOption {
+ default = pkgs.wpaperd;
+ defaultText = literalExpression "pkgs.wpaperd";
+ type = types.package;
+ example = literalExpression "pkgs.wpaperd";
+ description = "The package to use for the wpaperd binary.";
+ };
+
+ settings = mkOption {
+ type = tomlFormat.type;
+ description = ''
+ Configuration for wpaperd. Options are specified on:
+ https://github.com/danyspin97/wpaperd#wallpaper-configuration
+ '';
+ example = literalExpression ''
+ {
+ default = {
+ path = "/home/myusername/Pictures/Wallpapers/";
+ duration = "10m"
+ sorting = "random";
+ };
+ }
+ '';
+ };
+
+ systemdTarget = mkOption {
+ type = types.str;
+ default = "hyprland-session.target";
+ description = ''
+ Systemd target to bind to.
+ Note: if you're using home-manager to configure hyprland, you want to
+ have `wayland.windowManager.hyprland.systemdIntegration` enabled.
+ '';
+ };
+ };
+
+ config = mkIf cfg.enable {
+ assertions = [
+ (hm.assertions.assertPlatform "services.wpaperd" pkgs platforms.linux)
+ ];
+
+ home.packages = [ cfg.package ];
+
+ xdg.configFile = {
+ "wpaperd/wallpaper.toml" = mkIf (cfg.settings != { }) {
+ source = tomlFormat.generate "wpaperd-config" cfg.settings;
+ };
+ };
+
+ systemd.user.services.wpaperd = {
+ Unit = {
+ Description = "Wallpaper daemon for Wayland";
+ BindsTo = [ cfg.systemdTarget ];
+ };
+
+ Service = {
+ Type = "simple";
+ ExecStart = "${cfg.package}/bin/wpaperd --no-daemon";
+ };
+
+ Install.WantedBy = [ cfg.systemdTarget ];
+ };
+ };
+}