Files
nixos/Droidnix/generated/modules/traveldroid/desktop/wallpaper.nix
T
2026-03-29 11:32:49 +00:00

60 lines
1.4 KiB
Nix

{ config, pkgs, lib, flakeRoot, ... }:
let
username = config.defaultUser or "henrov";
homeDir = "/home/${username}";
wallpaperDst = "${homeDir}/Wallpapers";
wallpaperSrc = "${flakeRoot}/assets/traveldroid/Wallpapers";
in
{
############################
# Packages
############################
environment.systemPackages = with pkgs; [
swww
waypaper
jq
rsync
];
############################
# Service (does the work)
############################
systemd.user.services.wallpaperUpdater = {
description = "Sync wallpapers and apply them";
after = [ "default.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = ''
# Create destination folder
mkdir -p ${wallpaperDst}
# Copy FULL folder contents (mirror)
rsync -a --delete ${wallpaperSrc}/ ${wallpaperDst}/
# Ensure script is executable
chmod +x ${wallpaperDst}/set-wallpapers-per-workspace.sh
# Run script
${wallpaperDst}/set-wallpapers-per-workspace.sh
'';
};
};
############################
# Timer (runs every 15 min)
############################
systemd.user.timers.wallpaperUpdater = {
description = "Run wallpaper updater every 15 minutes";
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "2min"; # run shortly after login
OnUnitActiveSec = "15min"; # repeat every 15 min
Persistent = true;
};
};
}