Added nixos configs

This commit is contained in:
2026-02-22 19:25:39 +01:00
parent c0f19a200d
commit 8694deed28
9013 changed files with 118058 additions and 0 deletions
@@ -0,0 +1,87 @@
{ config, lib, pkgs, ... }:
# ====================== WALLPAPER=========================
let
# Source of wallpapers in your repo (as you specified)
srcDir = "~/nixos/files/wallpapers/picture";
# Note: this is interpreted as a shell-style KEY=VALUE file.
confFile = "~/nixos/files/conf/wallpaper/wallpaper.conf";
setWallpaperScript = pkgs.writeShellScript "set-hourly-wallpaper" ''
set -euo pipefail
# --- Defaults (can be overridden by wallpaper.conf) ---
TRANSITION_TYPE="fade" # e.g. fade, wipe, simple, any
TRANSITION_DURATION="2" # seconds (can be decimals)
TRANSITION_FPS="60" # frames per second
SRC_DIR="${srcDir}"
# Load overrides (shell KEY=VALUE)
if [ -f "${confFile}" ]; then
# shellcheck disable=SC1090
. "${confFile}"
fi
DEST_DIR="$HOME/Pictures/Wallpapers"
mkdir -p "$DEST_DIR"
# Copy source wallpapers into user's Pictures/Wallpapers
# -r recursive, -u update if newer
# If the folder is empty or missing, don't crash the session.
if [ -d "$SRC_DIR" ]; then
cp -ru "$SRC_DIR"/. "$DEST_DIR"/ 2>/dev/null || true
fi
# Pick a random image from DEST_DIR
img="$(
find "$DEST_DIR" -type f \
\( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.webp' \) \
| shuf -n 1
)"
[ -n "''${img:-}" ] || exit 0
# Ensure swww daemon is running (per-user)
if ! ${pkgs.swww}/bin/swww query >/dev/null 2>&1; then
${pkgs.swww}/bin/swww-daemon >/dev/null 2>&1 &
sleep 0.4
fi
# Smooth transition wallpaper set
exec ${pkgs.swww}/bin/swww img "$img" \
--transition-type "''${TRANSITION_TYPE}" \
--transition-duration "''${TRANSITION_DURATION}" \
--transition-fps "''${TRANSITION_FPS}"
'';
in
{
# Packages needed by the script + swww
environment.systemPackages = with pkgs; [
swww
bash
coreutils
findutils
util-linux
];
# Run for ANY logged-in user via systemd user units
# (each user session has its own systemd --user instance)
systemd.user.services.wallpaper-rotate = {
description = "Copy wallpapers to ~/Pictures/Wallpapers and set a random wallpaper with transition";
serviceConfig = {
Type = "oneshot";
ExecStart = "${setWallpaperScript}";
};
};
systemd.user.timers.wallpaper-rotate = {
description = "Hourly wallpaper rotation timer";
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "2min";
OnUnitActiveSec = "1h";
RandomizedDelaySec = "5min";
Unit = "wallpaper-rotate.service";
};
};
}