65 lines
1.9 KiB
Nix
65 lines
1.9 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
|
|
rsync
|
|
];
|
|
|
|
############################
|
|
# Systemd timer + service for wallpapers
|
|
############################
|
|
systemd.user.services.wallpaperUpdater = {
|
|
description = "Copy changed wallpapers and set them per workspace every 15 minutes";
|
|
after = [ "network.target" ];
|
|
|
|
serviceConfig.Type = "oneshot";
|
|
serviceConfig.ExecStart = ''
|
|
# Ensure destination exists
|
|
mkdir -p ${wallpaperDst}
|
|
|
|
# Copy only updated files using rsync
|
|
rsync -au --chmod=ugo+rx ${flakeRoot}/assets/traveldroid/Wallpapers/ ${wallpaperDst}/
|
|
|
|
# Ensure the script is executable
|
|
chmod +x ${wallpaperDst}/set-wallpapers-per-workspace.sh
|
|
|
|
# Run the wallpaper script
|
|
${wallpaperDst}/set-wallpapers-per-workspace.sh
|
|
'';
|
|
serviceConfig.Restart = "on-failure";
|
|
};
|
|
|
|
systemd.user.services.wallpaperUpdaterTimer = {
|
|
description = "Copy changed wallpapers and set them per workspace";
|
|
after = [ "network.target" ];
|
|
|
|
serviceConfig.Type = "oneshot";
|
|
serviceConfig.ExecStart = ''
|
|
mkdir -p ${wallpaperDst}
|
|
rsync -au --chmod=ugo+rx ${flakeRoot}/assets/traveldroid/Wallpapers/ ${wallpaperDst}/
|
|
chmod +x ${wallpaperDst}/set-wallpapers-per-workspace.sh
|
|
${wallpaperDst}/set-wallpapers-per-workspace.sh
|
|
'';
|
|
serviceConfig.Restart = "on-failure";
|
|
};
|
|
|
|
systemd.user.timers.wallpaperUpdaterTimer = {
|
|
description = "Run wallpaperUpdater service every 15 minutes";
|
|
wantedBy = [ "timers.target" ];
|
|
timerConfig.OnUnitActiveSec = "15min";
|
|
timerConfig.Persistent = true;
|
|
};
|
|
}
|