Regenerated
This commit is contained in:
@@ -7,7 +7,7 @@ source = ./layer-rules.conf
|
||||
source = ./layout.conf
|
||||
source = ./monitor-rules.conf
|
||||
# source = ./window-rules.conf
|
||||
# source = ./workspace-rules.conf
|
||||
source = ./workspace-rules.conf
|
||||
|
||||
|
||||
exec-once = /nix/store/c9cnbxhxbagj7gfpc1g5hl4x4f8dzayv-dbus-1.16.2/bin/dbus-update-activation-environment --systemd DISPLAY HYPRLAND_INSTANCE_SIGNATURE WAYLAND_DISPLAY XDG_CURRENT_DESKTOP XDG_SESSION_TYPE && systemctl --user stop hyprland-session.target && systemctl --user start hyprland-session.target
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
#Load random wallpaper
|
||||
workspacecreated = exec $HOME/.local/bin/wallpaper-sync-and-set.sh $workspace
|
||||
|
||||
/*
|
||||
|
||||
# Workspace definitions (modern syntax)
|
||||
workspace = 1
|
||||
workspace = 2
|
||||
@@ -5,6 +10,7 @@ workspace = 3
|
||||
workspace = 4
|
||||
workspace = 5
|
||||
|
||||
/*
|
||||
# Auto-launch apps on specific workspaces (use `exec` with `workspace` rule)
|
||||
exec-once = kitty, workspace 1
|
||||
exec-once = flatpak run app.betterbird.zen, workspace 2
|
||||
@@ -28,3 +34,5 @@ windowrule = move workspace 3, ^(libreoffice)$
|
||||
workspace {
|
||||
cycle_move_empty = no
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
@@ -1,77 +1,15 @@
|
||||
{ config, pkgs, lib, flakeRoot, ... }:
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
username = config.defaultUser or "henrov";
|
||||
homeDir = "/home/${username}";
|
||||
wallpaperSrc = "${flakeRoot}/assets/Wallpapers";
|
||||
wallpaperDst = "${homeDir}/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
|
||||
'';
|
||||
username = config.defaultUser or "henrov";
|
||||
homeDir = "/home/${username}";
|
||||
wallpaperDir = "${homeDir}/Wallpapers";
|
||||
scriptDest = "${homeDir}/Wallpapers/wallpaper-sync-and-set.sh";
|
||||
in
|
||||
{
|
||||
#################################
|
||||
# Packages
|
||||
#################################
|
||||
############################
|
||||
# Systemwide packages
|
||||
############################
|
||||
environment.systemPackages = with pkgs; [
|
||||
swww
|
||||
waypaper
|
||||
@@ -79,46 +17,36 @@ in
|
||||
rsync
|
||||
];
|
||||
|
||||
#################################
|
||||
# Service: main worker
|
||||
#################################
|
||||
############################
|
||||
# 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
|
||||
############################
|
||||
systemd.user.services.wallpaperSync = {
|
||||
description = "2-way sync wallpapers + set random per workspace";
|
||||
after = [ "graphical-session.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${script}";
|
||||
};
|
||||
|
||||
wantedBy = [ "default.target" ]; # run at login
|
||||
serviceConfig.Type = "oneshot";
|
||||
serviceConfig.ExecStart = "${scriptDest}";
|
||||
serviceConfig.Restart = "on-failure";
|
||||
};
|
||||
|
||||
#################################
|
||||
# Timer: every hour
|
||||
#################################
|
||||
systemd.user.timers.wallpaperSync = {
|
||||
description = "Run wallpaper sync hourly";
|
||||
|
||||
systemd.user.timers.wallpaperSyncTimer = {
|
||||
description = "Run wallpaper sync every hour";
|
||||
wantedBy = [ "timers.target" ];
|
||||
|
||||
timerConfig = {
|
||||
OnBootSec = "2min";
|
||||
OnUnitActiveSec = "1h";
|
||||
Persistent = true;
|
||||
};
|
||||
timerConfig.OnCalendar = "hourly";
|
||||
timerConfig.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}"
|
||||
'';
|
||||
############################
|
||||
# Run at login
|
||||
############################
|
||||
systemd.user.services.wallpaperSyncLogin = {
|
||||
description = "Run wallpaper sync at login";
|
||||
serviceConfig.Type = "oneshot";
|
||||
serviceConfig.ExecStart = "${scriptDest}";
|
||||
install.WantedBy = [ "default.target" ];
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user