52 lines
1.5 KiB
Nix
52 lines
1.5 KiB
Nix
{ config, pkgs, lib, flakeRoot, ... }:
|
|
|
|
let
|
|
username = config.defaultUser or "henrov";
|
|
homeDir = "/home/${username}";
|
|
wallpaperDst = "${homeDir}/Wallpapers";
|
|
scriptSrc = "${flakeRoot}/assets/traveldroid/Wallpapers/set-wallpapers-per-workspace.sh";
|
|
in
|
|
{
|
|
############################
|
|
# Packages
|
|
############################
|
|
environment.systemPackages = with pkgs; [
|
|
swww
|
|
waypaper
|
|
jq
|
|
];
|
|
|
|
############################
|
|
# Systemd timer + service for wallpapers
|
|
############################
|
|
systemd.user.services.wallpaperUpdater = {
|
|
description = "Copy wallpapers and set them per workspace every 15 minutes";
|
|
after = [ "network.target" ];
|
|
wants = [];
|
|
|
|
serviceConfig.Type = "oneshot";
|
|
serviceConfig.ExecStart = ''
|
|
# Ensure destination exists
|
|
mkdir -p ${wallpaperDst}
|
|
|
|
# Copy wallpapers from flake
|
|
cp -r ${flakeRoot}/assets/traveldroid/Wallpapers/* ${wallpaperDst}/
|
|
chown -R ${username}:${username} ${wallpaperDst}
|
|
chmod +x ${wallpaperDst}/set-wallpapers-per-workspace.sh
|
|
|
|
# Run the wallpaper script
|
|
${wallpaperDst}/set-wallpapers-per-workspace.sh
|
|
'';
|
|
# Optional: restart if it fails
|
|
serviceConfig.Restart = "on-failure";
|
|
};
|
|
|
|
systemd.user.timers.wallpaperUpdaterTimer = {
|
|
description = "Run wallpaperUpdater service every 15 minutes";
|
|
timerConfig.OnUnitActiveSec = "15min";
|
|
timerConfig.Persistent = true;
|
|
wantedBy = [ "timers.target" ];
|
|
unit = "wallpaperUpdater.service";
|
|
};
|
|
}
|