Files
nixos/Droidnix/generated/modules/traveldroid/desktop/wallpaper.nix
T
2026-03-26 14:39:13 +00:00

41 lines
1.2 KiB
Nix

{ lib, config, pkgs, flakeRoot, home-manager, inputs, ... }:
let
username = config.defaultUser or "henrov";
homeDir = "/home/${username}";
wallpaperDst = "${homeDir}/Wallpapers";
in
{
environment.systemPackages = with pkgs; [
swww # For setting wallpapers
waypaper # Optional, if you use it
jq # Needed by the script
];
# Copy Wallpapers from flake root to user's home
systemd.user.services.copyWallpapers = {
description = "Copy Wallpapers to home";
after = [ "network.target" ];
serviceConfig.Type = "oneshot";
serviceConfig.ExecStart = ''
mkdir -p ${wallpaperDst}
cp -r ${flakeRoot}/assets/traveldroid/Wallpapers/* ${wallpaperDst}/
chown -R ${username}:${username} ${wallpaperDst}
'';
install.wantedBy = [ "default.target" ];
};
# Place the script in the user's home
home.file.".config/wallpapers/set-wallpapers-per-workspace.sh".text = ''
#!/usr/bin/env bash
WALLS=("${wallpaperDst}"/*)
NUM_WALLS=${#WALLS[@]}
WS_IDS=($(hyprctl workspaces -j | jq -r '.[].id'))
for i in "${!WS_IDS[@]}"; do
WALL="${WALLS[$((i % NUM_WALLS))]}"
swww img "$WALL" --workspace "${WS_IDS[$i]}" --transition-type fade slide blend
done
'';
}