Regenerated

This commit is contained in:
2026-03-29 12:22:08 +00:00
parent 101ab20168
commit 5a471b0fd2
4 changed files with 404 additions and 372 deletions
+312 -316
View File
File diff suppressed because it is too large Load Diff
+24 -28
View File
@@ -2358,17 +2358,15 @@ workspace {
** =generated/modules/traveldroid/desktop/wallpaper.nix=
Setting up wallpaper engine + wallpaper gui
#+BEGIN_SRC nix :tangle generated/modules/traveldroid/desktop/wallpaper.nix :noweb yes :mkdirp yes :eval never
{ config, pkgs, lib, ... }:
{ config, pkgs, flakeRoot, ... }:
let
username = config.defaultUser or "henrov";
homeDir = "/home/${username}";
wallpaperDir = "${homeDir}/Wallpapers";
scriptDest = "${homeDir}/Wallpapers/wallpaper-sync-and-set.sh";
homeDir = "/home/${config.users.users."traveldroid".name or "traveldroid"}";
scriptFile = "${homeDir}/Wallpapers/script/set-wallpapers-at-logon.sh";
in
{
############################
# Systemwide packages
# System-wide packages
############################
environment.systemPackages = with pkgs; [
swww
@@ -2378,36 +2376,34 @@ in
];
############################
# Install the script
############################
home.file."Wallpapers/wallpaper-sync-and-set.sh".source = ./assets/Wallpapers/wallpaper-sync-and-set.sh;
home.file."Wallpapers/wallpaper-sync-and-set.sh".executable = true;
############################
# Systemd user service + timer
# User service: run the script
############################
systemd.user.services.wallpaperSync = {
description = "2-way sync wallpapers + set random per workspace";
serviceConfig.Type = "oneshot";
serviceConfig.ExecStart = "${scriptDest}";
serviceConfig.Restart = "on-failure";
};
description = "Run set-wallpapers-at-logon.sh";
systemd.user.timers.wallpaperSyncTimer = {
description = "Run wallpaper sync every hour";
wantedBy = [ "timers.target" ];
timerConfig.OnCalendar = "hourly";
timerConfig.Persistent = true;
serviceConfig.Type = "oneshot";
serviceConfig.ExecStart = scriptFile;
serviceConfig.Restart = "on-failure";
};
############################
# Run at login
# Timer: run service every 15 minutes
############################
systemd.user.timers.wallpaperSyncTimer = {
description = "Run wallpaperSync service every 15 minutes";
wantedBy = [ "timers.target" ];
timerConfig.OnUnitActiveSec = "15min";
timerConfig.Persistent = true;
};
############################
# Ensure the script runs at login
############################
systemd.user.services.wallpaperSyncLogin = {
description = "Run wallpaper sync at login";
serviceConfig.Type = "oneshot";
serviceConfig.ExecStart = "${scriptDest}";
install.WantedBy = [ "default.target" ];
description = "Run wallpaperSync at login";
wantedBy = [ "default.target" ];
serviceConfig.Type = "oneshot";
serviceConfig.ExecStart = scriptFile;
};
}
#+END_SRC
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
set -euo pipefail
# -----------------------------
# CONFIGURATION
# -----------------------------
# Repo path (first argument), fallback to current dir
REPO_DIR="${1:-$HOME/myrepo}"
SRC_WALLPAPERS="$REPO_DIR/assets/Wallpapers"
DST_WALLPAPERS="$HOME/Wallpapers"
PICTURES_DIR="$DST_WALLPAPERS/pictures"
# -----------------------------
# 2-WAY SYNC (only add/update, never delete)
# -----------------------------
mkdir -p "$DST_WALLPAPERS"
mkdir -p "$PICTURES_DIR"
# Sync from repo -> home (add/update)
rsync -au --ignore-existing "$SRC_WALLPAPERS/" "$DST_WALLPAPERS/"
# Sync from home -> repo (add only, no deletion)
rsync -au --ignore-existing "$DST_WALLPAPERS/" "$SRC_WALLPAPERS/"
# -----------------------------
# Set random wallpaper per workspace
# -----------------------------
# Get list of images
mapfile -t IMAGES < <(find "$PICTURES_DIR" -type f \( -iname '*.png' -o -iname '*.jpg' -o -iname '*.jpeg' \))
if [ "${#IMAGES[@]}" -eq 0 ]; then
echo "No images found in $PICTURES_DIR"
exit 1
fi
# Get number of workspaces (Hyprland / swww)
NUM_WORKSPACES=$(hyprctl workspaces | wc -l)
for ws in $(seq 1 "$NUM_WORKSPACES"); do
# Pick a random image
RAND_IMAGE="${IMAGES[RANDOM % ${#IMAGES[@]}]}"
# Set wallpaper for workspace
swww img "$RAND_IMAGE" --no-fade --transition-type none --workspace "$ws"
done
@@ -1,14 +1,12 @@
{ config, pkgs, lib, ... }:
{ config, pkgs, flakeRoot, ... }:
let
username = config.defaultUser or "henrov";
homeDir = "/home/${username}";
wallpaperDir = "${homeDir}/Wallpapers";
scriptDest = "${homeDir}/Wallpapers/wallpaper-sync-and-set.sh";
homeDir = "/home/${config.users.users."traveldroid".name or "traveldroid"}";
scriptFile = "${homeDir}/Wallpapers/script/set-wallpapers-at-logon.sh";
in
{
############################
# Systemwide packages
# System-wide packages
############################
environment.systemPackages = with pkgs; [
swww
@@ -18,35 +16,33 @@ in
];
############################
# Install the script
############################
home.file."Wallpapers/wallpaper-sync-and-set.sh".source = ./assets/Wallpapers/wallpaper-sync-and-set.sh;
home.file."Wallpapers/wallpaper-sync-and-set.sh".executable = true;
############################
# Systemd user service + timer
# User service: run the script
############################
systemd.user.services.wallpaperSync = {
description = "2-way sync wallpapers + set random per workspace";
serviceConfig.Type = "oneshot";
serviceConfig.ExecStart = "${scriptDest}";
serviceConfig.Restart = "on-failure";
};
description = "Run set-wallpapers-at-logon.sh";
systemd.user.timers.wallpaperSyncTimer = {
description = "Run wallpaper sync every hour";
wantedBy = [ "timers.target" ];
timerConfig.OnCalendar = "hourly";
timerConfig.Persistent = true;
serviceConfig.Type = "oneshot";
serviceConfig.ExecStart = scriptFile;
serviceConfig.Restart = "on-failure";
};
############################
# Run at login
# Timer: run service every 15 minutes
############################
systemd.user.timers.wallpaperSyncTimer = {
description = "Run wallpaperSync service every 15 minutes";
wantedBy = [ "timers.target" ];
timerConfig.OnUnitActiveSec = "15min";
timerConfig.Persistent = true;
};
############################
# Ensure the script runs at login
############################
systemd.user.services.wallpaperSyncLogin = {
description = "Run wallpaper sync at login";
serviceConfig.Type = "oneshot";
serviceConfig.ExecStart = "${scriptDest}";
install.WantedBy = [ "default.target" ];
description = "Run wallpaperSync at login";
wantedBy = [ "default.target" ];
serviceConfig.Type = "oneshot";
serviceConfig.ExecStart = scriptFile;
};
}