Regenerated
This commit is contained in:
+382
-317
File diff suppressed because it is too large
Load Diff
+94
-29
@@ -2354,13 +2354,75 @@ Setting up wallpaper engine + wallpaper gui
|
|||||||
let
|
let
|
||||||
username = config.defaultUser or "henrov";
|
username = config.defaultUser or "henrov";
|
||||||
homeDir = "/home/${username}";
|
homeDir = "/home/${username}";
|
||||||
|
wallpaperSrc = "${flakeRoot}/assets/Wallpapers";
|
||||||
wallpaperDst = "${homeDir}/Wallpapers";
|
wallpaperDst = "${homeDir}/Wallpapers";
|
||||||
wallpaperSrc = "${flakeRoot}/assets/traveldroid/Wallpapers";
|
|
||||||
|
script = pkgs.writeShellScript "wallpaper-sync-and-set.sh" ''
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SRC="${wallpaperSrc}"
|
||||||
|
DST="${wallpaperDst}"
|
||||||
|
|
||||||
|
mkdir -p "$SRC" "$DST"
|
||||||
|
|
||||||
|
########################################
|
||||||
|
# 2-way sync (additive, newer wins)
|
||||||
|
########################################
|
||||||
|
|
||||||
|
# SRC -> DST
|
||||||
|
rsync -au "$SRC/" "$DST/"
|
||||||
|
|
||||||
|
# DST -> SRC
|
||||||
|
rsync -au "$DST/" "$SRC/"
|
||||||
|
|
||||||
|
########################################
|
||||||
|
# Initialize swww (safe if already running)
|
||||||
|
########################################
|
||||||
|
if ! pgrep -x swww-daemon >/dev/null; then
|
||||||
|
swww init
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
########################################
|
||||||
|
# Get workspaces
|
||||||
|
########################################
|
||||||
|
WORKSPACES=$(hyprctl workspaces -j | jq -r '.[].id')
|
||||||
|
|
||||||
|
########################################
|
||||||
|
# Function: set random wallpaper for workspace
|
||||||
|
########################################
|
||||||
|
set_wallpaper() {
|
||||||
|
local WS="$1"
|
||||||
|
|
||||||
|
WALL=$(find "$DST" -type f | shuf -n 1)
|
||||||
|
|
||||||
|
if [ -n "$WALL" ]; then
|
||||||
|
hyprctl dispatch workspace "$WS"
|
||||||
|
swww img "$WALL" --transition-type any
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
########################################
|
||||||
|
# If workspace passed → only update that
|
||||||
|
########################################
|
||||||
|
if [ "$#" -eq 1 ]; then
|
||||||
|
set_wallpaper "$1"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
########################################
|
||||||
|
# Otherwise: update all workspaces
|
||||||
|
########################################
|
||||||
|
for WS in $WORKSPACES; do
|
||||||
|
set_wallpaper "$WS"
|
||||||
|
done
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
############################
|
#################################
|
||||||
# Packages
|
# Packages
|
||||||
############################
|
#################################
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
swww
|
swww
|
||||||
waypaper
|
waypaper
|
||||||
@@ -2368,45 +2430,48 @@ in
|
|||||||
rsync
|
rsync
|
||||||
];
|
];
|
||||||
|
|
||||||
############################
|
#################################
|
||||||
# Service (does the work)
|
# Service: main worker
|
||||||
############################
|
#################################
|
||||||
systemd.user.services.wallpaperUpdater = {
|
systemd.user.services.wallpaperSync = {
|
||||||
description = "Sync wallpapers and apply them";
|
description = "2-way sync wallpapers + set random per workspace";
|
||||||
after = [ "default.target" ];
|
after = [ "graphical-session.target" ];
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
ExecStart = ''
|
ExecStart = "${script}";
|
||||||
# Create destination folder
|
|
||||||
mkdir -p ${wallpaperDst}
|
|
||||||
|
|
||||||
# Copy FULL folder contents (mirror)
|
|
||||||
rsync -a --delete ${wallpaperSrc}/ ${wallpaperDst}/
|
|
||||||
|
|
||||||
# Ensure script is executable
|
|
||||||
chmod +x ${wallpaperDst}/set-wallpapers-per-workspace.sh
|
|
||||||
|
|
||||||
# Run script
|
|
||||||
${wallpaperDst}/set-wallpapers-per-workspace.sh
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wantedBy = [ "default.target" ]; # run at login
|
||||||
};
|
};
|
||||||
|
|
||||||
############################
|
#################################
|
||||||
# Timer (runs every 15 min)
|
# Timer: every hour
|
||||||
############################
|
#################################
|
||||||
systemd.user.timers.wallpaperUpdater = {
|
systemd.user.timers.wallpaperSync = {
|
||||||
description = "Run wallpaper updater every 15 minutes";
|
description = "Run wallpaper sync hourly";
|
||||||
|
|
||||||
wantedBy = [ "timers.target" ];
|
wantedBy = [ "timers.target" ];
|
||||||
|
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
OnBootSec = "2min"; # run shortly after login
|
OnBootSec = "2min";
|
||||||
OnUnitActiveSec = "15min"; # repeat every 15 min
|
OnUnitActiveSec = "1h";
|
||||||
Persistent = true;
|
Persistent = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#################################
|
||||||
|
# Hyprland integration (new workspace)
|
||||||
|
#################################
|
||||||
|
# This assumes you manage Hyprland via Nix/Home Manager
|
||||||
|
#################################
|
||||||
|
environment.etc."hypr/hyprland.conf".text = lib.mkAfter ''
|
||||||
|
# Run wallpaper script when workspace changes
|
||||||
|
bind = SUPER, Return, exec, ${script}
|
||||||
|
|
||||||
|
# Hook: when workspace is created/switched
|
||||||
|
exec-once = hyprctl --batch "dispatch exec ${script}"
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,75 @@
|
|||||||
let
|
let
|
||||||
username = config.defaultUser or "henrov";
|
username = config.defaultUser or "henrov";
|
||||||
homeDir = "/home/${username}";
|
homeDir = "/home/${username}";
|
||||||
|
wallpaperSrc = "${flakeRoot}/assets/Wallpapers";
|
||||||
wallpaperDst = "${homeDir}/Wallpapers";
|
wallpaperDst = "${homeDir}/Wallpapers";
|
||||||
wallpaperSrc = "${flakeRoot}/assets/traveldroid/Wallpapers";
|
|
||||||
|
script = pkgs.writeShellScript "wallpaper-sync-and-set.sh" ''
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SRC="${wallpaperSrc}"
|
||||||
|
DST="${wallpaperDst}"
|
||||||
|
|
||||||
|
mkdir -p "$SRC" "$DST"
|
||||||
|
|
||||||
|
########################################
|
||||||
|
# 2-way sync (additive, newer wins)
|
||||||
|
########################################
|
||||||
|
|
||||||
|
# SRC -> DST
|
||||||
|
rsync -au "$SRC/" "$DST/"
|
||||||
|
|
||||||
|
# DST -> SRC
|
||||||
|
rsync -au "$DST/" "$SRC/"
|
||||||
|
|
||||||
|
########################################
|
||||||
|
# Initialize swww (safe if already running)
|
||||||
|
########################################
|
||||||
|
if ! pgrep -x swww-daemon >/dev/null; then
|
||||||
|
swww init
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
########################################
|
||||||
|
# Get workspaces
|
||||||
|
########################################
|
||||||
|
WORKSPACES=$(hyprctl workspaces -j | jq -r '.[].id')
|
||||||
|
|
||||||
|
########################################
|
||||||
|
# Function: set random wallpaper for workspace
|
||||||
|
########################################
|
||||||
|
set_wallpaper() {
|
||||||
|
local WS="$1"
|
||||||
|
|
||||||
|
WALL=$(find "$DST" -type f | shuf -n 1)
|
||||||
|
|
||||||
|
if [ -n "$WALL" ]; then
|
||||||
|
hyprctl dispatch workspace "$WS"
|
||||||
|
swww img "$WALL" --transition-type any
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
########################################
|
||||||
|
# If workspace passed → only update that
|
||||||
|
########################################
|
||||||
|
if [ "$#" -eq 1 ]; then
|
||||||
|
set_wallpaper "$1"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
########################################
|
||||||
|
# Otherwise: update all workspaces
|
||||||
|
########################################
|
||||||
|
for WS in $WORKSPACES; do
|
||||||
|
set_wallpaper "$WS"
|
||||||
|
done
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
############################
|
#################################
|
||||||
# Packages
|
# Packages
|
||||||
############################
|
#################################
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
swww
|
swww
|
||||||
waypaper
|
waypaper
|
||||||
@@ -17,43 +79,46 @@ in
|
|||||||
rsync
|
rsync
|
||||||
];
|
];
|
||||||
|
|
||||||
############################
|
#################################
|
||||||
# Service (does the work)
|
# Service: main worker
|
||||||
############################
|
#################################
|
||||||
systemd.user.services.wallpaperUpdater = {
|
systemd.user.services.wallpaperSync = {
|
||||||
description = "Sync wallpapers and apply them";
|
description = "2-way sync wallpapers + set random per workspace";
|
||||||
after = [ "default.target" ];
|
after = [ "graphical-session.target" ];
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
ExecStart = ''
|
ExecStart = "${script}";
|
||||||
# Create destination folder
|
|
||||||
mkdir -p ${wallpaperDst}
|
|
||||||
|
|
||||||
# Copy FULL folder contents (mirror)
|
|
||||||
rsync -a --delete ${wallpaperSrc}/ ${wallpaperDst}/
|
|
||||||
|
|
||||||
# Ensure script is executable
|
|
||||||
chmod +x ${wallpaperDst}/set-wallpapers-per-workspace.sh
|
|
||||||
|
|
||||||
# Run script
|
|
||||||
${wallpaperDst}/set-wallpapers-per-workspace.sh
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wantedBy = [ "default.target" ]; # run at login
|
||||||
};
|
};
|
||||||
|
|
||||||
############################
|
#################################
|
||||||
# Timer (runs every 15 min)
|
# Timer: every hour
|
||||||
############################
|
#################################
|
||||||
systemd.user.timers.wallpaperUpdater = {
|
systemd.user.timers.wallpaperSync = {
|
||||||
description = "Run wallpaper updater every 15 minutes";
|
description = "Run wallpaper sync hourly";
|
||||||
|
|
||||||
wantedBy = [ "timers.target" ];
|
wantedBy = [ "timers.target" ];
|
||||||
|
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
OnBootSec = "2min"; # run shortly after login
|
OnBootSec = "2min";
|
||||||
OnUnitActiveSec = "15min"; # repeat every 15 min
|
OnUnitActiveSec = "1h";
|
||||||
Persistent = true;
|
Persistent = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#################################
|
||||||
|
# Hyprland integration (new workspace)
|
||||||
|
#################################
|
||||||
|
# This assumes you manage Hyprland via Nix/Home Manager
|
||||||
|
#################################
|
||||||
|
environment.etc."hypr/hyprland.conf".text = lib.mkAfter ''
|
||||||
|
# Run wallpaper script when workspace changes
|
||||||
|
bind = SUPER, Return, exec, ${script}
|
||||||
|
|
||||||
|
# Hook: when workspace is created/switched
|
||||||
|
exec-once = hyprctl --batch "dispatch exec ${script}"
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user