Added lib.mkForce + backup = false

This commit is contained in:
2026-03-01 17:23:50 +01:00
parent 9e8c030646
commit 72006f36ea
47 changed files with 5121 additions and 5058 deletions
@@ -7,44 +7,44 @@ let
userVideoPath = "${userAbsRoot}/videos/myWallpaper.mp4";
# (keep your existing approach: sync the repo wallpaper dir to the user dir)
repoWallpapersOnly = lib.cleanSourceWith {
src = repoWallpaperDir;
filter = path: type: true;
src = repoWallpaperDir;
filter = path: type: true;
};
in
{
home.packages = [
pkgs.mpvpaper
pkgs.mpv
pkgs.mpvpaper
pkgs.mpv
];
# Sync repo wallpapers (including videos/) into ~/nixos_conf/wallpaperstuff
home.file."${userRelRoot}" = {
source = repoWallpapersOnly;
recursive = true;
source = repoWallpapersOnly;
recursive = true;
};
systemd.user.services.mpvpaper-wallpaper = {
Unit = {
Description = "Video wallpaper (mpvpaper)";
After = [ "graphical-session.target" ];
PartOf = [ "graphical-session.target" ];
};
Service = {
Type = "simple";
# -p auto-pause saves resources when the wallpaper surface is hidden.
# '*' applies to all outputs.
# Stretch-to-fill (cover) behavior:
# --panscan=1.0 fills the entire output by cropping (no letterboxing).
# If you literally want distortion-stretch (ignore aspect ratio), use --keepaspect=no instead.
ExecStart = ''
${pkgs.mpvpaper}/bin/mpvpaper \
-p \
-o "no-audio --loop-file=inf --no-terminal --really-quiet --panscan=1.0 --keepaspect=yes" \
'*' "${userVideoPath}"
'';
Restart = "on-failure";
RestartSec = 1;
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
Unit = {
Description = "Video wallpaper (mpvpaper)";
After = [ "graphical-session.target" ];
PartOf = [ "graphical-session.target" ];
};
Service = {
Type = "simple";
# -p auto-pause saves resources when the wallpaper surface is hidden.
# '*' applies to all outputs.
# Stretch-to-fill (cover) behavior:
# --panscan=1.0 fills the entire output by cropping (no letterboxing).
# If you literally want distortion-stretch (ignore aspect ratio), use --keepaspect=no instead.
ExecStart = ''
${pkgs.mpvpaper}/bin/mpvpaper \
-p \
-o "no-audio --loop-file=inf --no-terminal --really-quiet --panscan=1.0 --keepaspect=yes" \
'*' "${userVideoPath}"
'';
Restart = "on-failure";
RestartSec = 1;
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
};
}
+20 -20
View File
@@ -1,28 +1,28 @@
{ config, lib, pkgs, ... }:
{
wayland.windowManager.hyprland = {
# Load the Hyprexpo plugin (from nixpkgs)
plugins = [
pkgs.hyprlandPlugins.hyprexpo
];
# Load the Hyprexpo plugin (from nixpkgs)
plugins = [
pkgs.hyprlandPlugins.hyprexpo
];
# Append plugin config + keybind after your existing hyprland.conf
extraConfig = lib.mkAfter ''
############################
# Hyprexpo (workspace/window overview)
############################
# Append plugin config + keybind after your existing hyprland.conf
extraConfig = lib.mkAfter ''
############################
# Hyprexpo (workspace/window overview)
############################
# Basic plugin config (tweak as you like)
plugin {
hyprexpo {
columns = 3
gaps_in = 5
gaps_out = 20
# Basic plugin config (tweak as you like)
plugin {
hyprexpo {
columns = 3
gaps_in = 5
gaps_out = 20
# Optional; comment out if you don't want it
# workspace_method = center current
}
}
'';
# Optional; comment out if you don't want it
# workspace_method = center current
}
}
'';
};
}
+2 -1
View File
@@ -4,5 +4,6 @@ let
in
{
home.packages = [ pkgs.hypridle ];
xdg.configFile."hypr/hypridle.conf".source = hypridleConf;
xdg.configFile."hypr/hypridle.conf".source = lib.mkForce hypridleConf;
xdg.configFile."hypr/hypridle.conf".backup = lib.mkForce false ;
}
+28 -27
View File
@@ -1,40 +1,41 @@
{ config, lib, pkgs, flakeRoot, ... }:
let
hyprConf = flakeRoot + "/assets/conf/desktop/hypr/hyprland.conf";
hyprConf = flakeRoot + "/assets/conf/desktop/hypr/hyprland.conf";
bindingsConf = flakeRoot + "/assets/conf/desktop/hypr/bindings.conf";
in
{
wayland.windowManager.hyprland = {
enable = true;
# Load base config + bindings from repo files
extraConfig =
(builtins.readFile hyprConf)
+ "\n\n# --- Repo keybindings ---\n"
+ (builtins.readFile bindingsConf)
+ "\n";
settings = {
windowrule = [
"match:class nm-connection-editor, float 1, center 1, size 900 700"
];
};
enable = true;
# Load base config + bindings from repo files
extraConfig =
(builtins.readFile hyprConf)
+ "\n\n# --- Repo keybindings ---\n"
+ (builtins.readFile bindingsConf)
+ "\n";
settings = {
windowrule = [
"match:class nm-connection-editor, float 1, center 1, size 900 700"
];
};
};
xdg.configFile."hypr/scripts/lid-lock.sh" = {
source = flakeRoot + "/assets/conf/desktop/hypr/scripts/lid-lock.sh";
executable = true;
source = lib.mkForce flakeRoot + "/assets/conf/desktop/hypr/scripts/lid-lock.sh";
backup = lib.mkForce false;
executable = true;
};
xdg.portal = {
enable = true;
extraPortals = with pkgs; [
xdg-desktop-portal-gtk
xdg-desktop-portal-hyprland
];
# GTK als algemene backend (OpenURI is daar betrouwbaar)
config.common.default = [ "gtk" ];
# Hyprland alleen voor screensharing / remote desktop
config.hyprland = {
"org.freedesktop.impl.portal.Screencast" = [ "hyprland" ];
"org.freedesktop.impl.portal.RemoteDesktop" = [ "hyprland" ];
};
enable = true;
extraPortals = with pkgs; [
xdg-desktop-portal-gtk
xdg-desktop-portal-hyprland
];
# GTK als algemene backend (OpenURI is daar betrouwbaar)
config.common.default = [ "gtk" ];
# Hyprland alleen voor screensharing / remote desktop
config.hyprland = {
"org.freedesktop.impl.portal.Screencast" = [ "hyprland" ];
"org.freedesktop.impl.portal.RemoteDesktop" = [ "hyprland" ];
};
};
}
+5 -3
View File
@@ -1,10 +1,12 @@
{config, lib, pkgs, flakeRoot, ... }:
let
lockPngSrc = flakeRoot + "/assets/lock.png";
lockPngSrc = flakeRoot + "/assets/lock.png";
hyprlockConf = flakeRoot + "/assets/conf/desktop/hypr/hyprlock.conf";
in
{
home.packages = [ pkgs.hyprlock ];
xdg.configFile."hypr/lock.png".source = lockPngSrc;
xdg.configFile."hypr/hyprlock.conf".source = hyprlockConf;
xdg.configFile."hypr/lock.png".source = lib.mkForce lockPngSrc;
xdg.configFile."hypr/lock.png".backup = lib.mkForce false;
xdg.configFile."hypr/hyprlock.conf".source = lib.mkForce hyprlockConf;
xdg.configFile."hypr/hyprlock.conf".backup = lib.mkForce false;
}
+20 -17
View File
@@ -11,37 +11,40 @@ let
targetPerMonitor = "hypr/scripts/hyprscrolling-per-monitor.sh";
# Facilitate switching between scrolling and dwindle
repoSwitchScript =
flakeRoot + "/assets/conf/desktop/hypr/scripts/toggle-layout-scrolling-dwindle.sh";
flakeRoot + "/assets/conf/desktop/hypr/scripts/toggle-layout-scrolling-dwindle.sh";
targetSwitchScript = "hypr/scripts/toggle-layout-scrolling-dwindle.sh";
in
{
# Ensure deps for the script exist at runtime
# (hyprctl comes with Hyprland; jq is often not installed by default)
home.packages = with pkgs; [
jq
jq
];
wayland.windowManager.hyprland = {
enable = true;
plugins = [
pkgs.hyprlandPlugins.hyprscrolling
];
extraConfig = ''
source = ~/.config/${targetRel}
'';
enable = true;
plugins = [
pkgs.hyprlandPlugins.hyprscrolling
];
extraConfig = ''
source = ~/.config/${targetRel}
'';
};
# Copy repo configs/scripts into ~/.config
xdg.configFile."${targetRel}".source = repoConf;
xdg.configFile."${targetRel}".source = lib.mkForce repoConf;
xdg.configFile."${targetRel}".backup = lib.mkForce false;
xdg.configFile."${targetOverflowRel}" = {
source = repoOverflowScript;
executable = true; # makes it chmod +x
source = lib.mkForce repoOverflowScript;
backup = lib.mkForce false;
executable = true; # makes it chmod +x
};
xdg.configFile."${targetPerMonitor}" = {
source = repoPerMonitorScript;
executable = true; # makes it chmod +x
source = lib.mkForce repoPerMonitorScript;
backup = lib.mkForce false;
executable = true; # makes it chmod +x
};
xdg.configFile."${targetSwitchScript}" = {
source = repoSwitchScript;
executable = true; # makes it chmod +x
source = lib.mkForce repoSwitchScript;
backup = lib.mkForce false;
executable = true; # makes it chmod +x
};
}
+17 -15
View File
@@ -9,22 +9,24 @@ in
xdg.enable = true;
home.packages = [ pkgs.hyprshell ];
# Link repo -> ~/.config/hyprshell/...
xdg.configFile."hyprshell/config.ron".source = cfgRon;
xdg.configFile."hyprshell/styles.css".source = cssFile;
xdg.configFile."hyprshell/config.ron".source = lib.mkForce cfgRon;
xdg.configFile."hyprshell/config.ron".backup = lib.mkForce false;
xdg.configFile."hyprshell/styles.css".source = lib.mkForce cssFile;
xdg.configFile."hyprshell/styles.css".backup = lib.mkForce false;
# Autostart (systemd user service)
systemd.user.services.hyprshell = {
Unit = {
Description = "Hyprshell (window switcher / launcher)";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
};
Service = {
ExecStart = "${pkgs.hyprshell}/bin/hyprshell";
Restart = "on-failure";
RestartSec = 1;
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
Unit = {
Description = "Hyprshell (window switcher / launcher)";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
};
Service = {
ExecStart = "${pkgs.hyprshell}/bin/hyprshell";
Restart = "on-failure";
RestartSec = 1;
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
};
}
+4 -3
View File
@@ -1,13 +1,14 @@
{ config, lib, pkgs, flakeRoot, ... }:
let
repoScript =
flakeRoot + "/assets/conf/desktop/hypr/scripts/powermenu.sh";
flakeRoot + "/assets/conf/desktop/hypr/scripts/powermenu.sh";
targetRel = "hypr/scripts/powermenu.sh";
in
{
# Ensure script exists in ~/.config/hypr/scripts/
xdg.configFile."${targetRel}" = {
source = repoScript;
executable = true;
source = lib.mkForce repoScript;
backup = lib.mkForce false;
executable = true;
};
}
@@ -8,35 +8,35 @@ let
userConfPath = "${userAbsRoot}/wallpaper.conf";
# Exclude wallpaper.conf so HM does NOT manage it (avoids backup collisions)
repoWallpapersOnly = lib.cleanSourceWith {
src = repoWallpaperDir;
filter = path: type:
(builtins.baseNameOf path) != "wallpaper.conf";
src = repoWallpaperDir;
filter = path: type:
(builtins.baseNameOf path) != "wallpaper.conf";
};
in
{
home.packages = [ pkgs.wpaperd ];
# Sync everything *except* wallpaper.conf into ~/nixos_conf/wallpaperstuff
home.file."${userRelRoot}" = {
source = repoWallpapersOnly;
recursive = true;
source = repoWallpapersOnly;
recursive = true;
};
# Now safely overwrite the config every activation (no HM collision)
home.activation.wallpaperConfForce =
lib.hm.dag.entryAfter [ "writeBoundary" ] ''
set -euo pipefail
mkdir -p "${userAbsRoot}"
install -m 0644 "${repoWallpaperConf}" "${userConfPath}"
'';
lib.hm.dag.entryAfter [ "writeBoundary" ] ''
set -euo pipefail
mkdir -p "${userAbsRoot}"
install -m 0644 "${repoWallpaperConf}" "${userConfPath}"
'';
systemd.user.services.wpaperd = {
Unit = {
Description = "wpaperd wallpaper daemon";
After = [ "default.target" ];
};
Service = {
Type = "simple";
ExecStart = "${pkgs.wpaperd}/bin/wpaperd --config ${userConfPath}";
Restart = "on-failure";
RestartSec = 1;
};
Install.WantedBy = [ "default.target" ];
Unit = {
Description = "wpaperd wallpaper daemon";
After = [ "default.target" ];
};
Service = {
Type = "simple";
ExecStart = "${pkgs.wpaperd}/bin/wpaperd --config ${userConfPath}";
Restart = "on-failure";
RestartSec = 1;
};
Install.WantedBy = [ "default.target" ];
;
+13 -9
View File
@@ -1,13 +1,13 @@
{ config, pkgs, lib, flakeRoot, inputs ? null, ... }:
let
walkerPkg =
if inputs != null && inputs ? walker
then inputs.walker.packages.${pkgs.system}.default
else pkgs.walker;
if inputs != null && inputs ? walker
then inputs.walker.packages.${pkgs.system}.default
else pkgs.walker;
elephantPkg =
if inputs != null && inputs ? elephant
then inputs.elephant.packages.${pkgs.system}.default
else pkgs.elephant;
if inputs != null && inputs ? elephant
then inputs.elephant.packages.${pkgs.system}.default
else pkgs.elephant;
sessionTarget = "graphical-session.target";
# All theme files now live here
repoThemesDir = flakeRoot + "/assets/conf/desktop/walker";
@@ -16,11 +16,15 @@ in
xdg.enable = true;
home.packages = [ walkerPkg elephantPkg ];
# ~/.config/walker/themes/*
xdg.configFile."walker/themes/frosted/default.css".source = repoThemesDir + "/themes/frosted/default.css";
xdg.configFile."walker/themes/frosted/default.css".source = lib.mkForce repoThemesDir + "/themes/frosted/default.css";
xdg.configFile."walker/themes/frosted/default.css".backup = lib.mkForce false;
xdg.configFile."walker/themes/frosted/style.css".source = repoThemesDir + "/themes/frosted/style.css";
xdg.configFile."walker/themes/frosted/style.css".backup = lib.mkForce false;
xdg.configFile."walker/config.toml".source = repoThemesDir + "/config.toml";
# xdg.configFile."walker/themes/default.html".source = repoThemesDir + "/default.html";
xdg.configFile."walker/config.toml".backup = lib.mkForce false;
# xdg.configFile."walker/themes/default.html".source = lib.mkForce repoThemesDir + "/default.html";
# xdg.configFile."walker/themes/default.html".backup = lib.mkForce false;
# (services unchanged)
systemd.user.services.elephant = { /* ... your existing service ... */ };
systemd.user.services.walker = { /* ... your existing service ... */ };
systemd.user.services.walker = { /* ... your existing service ... */ };
}
+6 -4
View File
@@ -6,14 +6,16 @@ in
programs.waybar.enable = true;
# Ensure config matches repo (HM-managed symlink, not user-editable)
xdg.configFile."waybar/config" = {
source = repoWaybarDir + "/config.jsonc";
force = true;
source = lib.mkForce repoWaybarDir + "/config.jsonc";
backup = lib.mkForce false;
force = true;
};
# Override HM's internally-generated waybar-style.css derivation
# and use your repo file instead.
xdg.configFile."waybar/style.css" = {
source = lib.mkForce (repoWaybarDir + "/style.css");
force = true;
source = lib.mkForce (repoWaybarDir + "/style.css");
backup = lib.mkForce false;
force = true;
};
# Prevent HM from also trying to generate style content via programs.waybar.style
# (not strictly required once mkForce is in place, but keeps intent clear)
+159 -156
View File
@@ -7,197 +7,200 @@ let
# (Optional) still sync your repo wallpapers/scripts into ~/nixos_conf/wallpaperstuff
repoWallpaperDir = flakeRoot + "/assets/conf/desktop/wallpaper";
repoWallpapersOnly = lib.cleanSourceWith {
src = repoWallpaperDir;
filter = path: type: true;
src = repoWallpaperDir;
filter = path: type: true;
};
daemonRel = "hypr/scripts/hyprpaper-ws-daemon.sh";
setRel = "hypr/scripts/set-wallpaper.sh";
setRel = "hypr/scripts/set-wallpaper.sh";
in
{
home.packages = [
pkgs.hyprpaper
pkgs.socat
pkgs.jq
pkgs.findutils
pkgs.coreutils
pkgs.gnused
pkgs.gawk
pkgs.hyprpaper
pkgs.socat
pkgs.jq
pkgs.findutils
pkgs.coreutils
pkgs.gnused
pkgs.gawk
];
# Keep your existing "sync wallpapers into a writable dir" pattern
home.file."${userRelRoot}" = {
source = repoWallpapersOnly;
recursive = true;
source = repoWallpapersOnly;
recursive = true;
};
# Hyprpaper config (hyprpaper reads this; it does NOT need to write it)
# `ipc = true` enables `hyprctl hyprpaper ...` commands. :contentReference[oaicite:0]{index=0}
xdg.configFile."hypr/hyprpaper.conf".text = ''
ipc = true
splash = false
xdg.configFile."hypr/hyprpaper.conf".text = lib.mkForce ''
ipc = true
splash = false
'';
xdg.configFile."hypr/hyprpaper.conf".backup = lib.mkForce false;
# Workspace wallpaper daemon: listens to socket2, applies w-<id>=... mapping
# Uses workspacev2 to get numeric workspace id. :contentReference[oaicite:1]{index=1}
xdg.configFile."${daemonRel}" = {
executable = true;
text = ''
#!/usr/bin/env bash
set -euo pipefail
: "''${XDG_RUNTIME_DIR:?XDG_RUNTIME_DIR not set}"
: "''${HYPRLAND_INSTANCE_SIGNATURE:?HYPRLAND_INSTANCE_SIGNATURE not set}"
SOCK="''${XDG_RUNTIME_DIR}/hypr/''${HYPRLAND_INSTANCE_SIGNATURE}/.socket2.sock"
[[ -S "$SOCK" ]] || { echo "Hyprland socket not found: $SOCK" >&2; exit 1; }
PICTURES_DIR="''${1:-${picturesDir}}"
FIT_MODE="fill" # hyprpaper fit_mode: contain|cover|tile|fill :contentReference[oaicite:2]{index=2}
HYPR_DIR="''${XDG_CONFIG_HOME:-$HOME/.config}/hypr"
MAP_ROOT="''${HYPR_DIR}/hyprpaper/config"
focused_monitor() {
hyprctl -j monitors | jq -r '.[] | select(.focused==true) | .name' | head -n 1
}
map_file_for_monitor() {
local mon="''${1}"
echo "''${MAP_ROOT}/''${mon}/defaults.conf"
}
ensure_map_file() {
local mon="''${1}"
local f
f="$(map_file_for_monitor "''${mon}")"
mkdir -p "$(dirname "''${f}")"
if [[ ! -f "''${f}" ]]; then
# Seed with 1..9 from picturesDir if present, else empty entries
{
for i in 1 2 3 4 5 6 7 8 9; do
seed="$(ls -1 "''${PICTURES_DIR}/''${i}."* 2>/dev/null | head -n 1 || true)"
echo "w-''${i}= ''${seed}"
done
} > "''${f}"
fi
echo "''${f}"
}
get_wall_for_ws() {
local mon="''${1}"
local wsid="''${2}"
local f key val
f="$(ensure_map_file "''${mon}")"
key="w-''${wsid}"
# accept "w-1=/path" or "w-1= /path"
val="$(awk -F= -v k="''${key}" '$1==k {sub(/^[[:space:]]+/, "", $2); print $2; exit}' "''${f}" || true)"
echo "''${val}"
}
apply_wallpaper() {
local mon="''${1}"
local wsid="''${2}"
local file
file="$(get_wall_for_ws "''${mon}" "''${wsid}")"
[[ -n "''${file}" ]] || return 0
[[ -f "''${file}" ]] || return 0
# Apply via IPC
# hyprpaper wallpaper { monitor path fit_mode } model is per monitor. :contentReference[oaicite:3]{index=3}
hyprctl hyprpaper wallpaper "''${mon}, ''${file}, ''${FIT_MODE}" >/dev/null
}
# Initial apply on startup
mon="$(focused_monitor || true)"
wsid="$(hyprctl -j activeworkspace | jq -r '.id' | head -n 1 || true)"
[[ -n "''${mon}" && -n "''${wsid}" ]] && apply_wallpaper "''${mon}" "''${wsid}"
handle() {
local line="''${1}"
case "''${line}" in
workspacev2* )
# workspacev2>>ID,NAME :contentReference[oaicite:4]{index=4}
local payload wsid
payload="''${line#*>>}"
wsid="''${payload%%,*}"
mon="$(focused_monitor || true)"
[[ -n "''${mon}" && -n "''${wsid}" ]] && apply_wallpaper "''${mon}" "''${wsid}"
;;
focusedmon* )
# focusedmon>>MON,WORKSPACENAME :contentReference[oaicite:5]{index=5}
# When monitor focus changes, re-apply for the active workspace id.
mon="$(focused_monitor || true)"
wsid="$(hyprctl -j activeworkspace | jq -r '.id' | head -n 1 || true)"
[[ -n "''${mon}" && -n "''${wsid}" ]] && apply_wallpaper "''${mon}" "''${wsid}"
;;
esac
}
socat -U - UNIX-CONNECT:"''${SOCK}" | while read -r line; do
handle "''${line}" || true
done
'';
executable = true;
text = lib.mkForce ''
#!/usr/bin/env bash
set -euo pipefail
: "''${XDG_RUNTIME_DIR:?XDG_RUNTIME_DIR not set}"
: "''${HYPRLAND_INSTANCE_SIGNATURE:?HYPRLAND_INSTANCE_SIGNATURE not set}"
SOCK="''${XDG_RUNTIME_DIR}/hypr/''${HYPRLAND_INSTANCE_SIGNATURE}/.socket2.sock"
[[ -S "$SOCK" ]] || { echo "Hyprland socket not found: $SOCK" >&2; exit 1; }
PICTURES_DIR="''${1:-${picturesDir}}"
FIT_MODE="fill" # hyprpaper fit_mode: contain|cover|tile|fill :contentReference[oaicite:2]{index=2}
HYPR_DIR="''${XDG_CONFIG_HOME:-$HOME/.config}/hypr"
MAP_ROOT="''${HYPR_DIR}/hyprpaper/config"
focused_monitor() {
hyprctl -j monitors | jq -r '.[] | select(.focused==true) | .name' | head -n 1
}
map_file_for_monitor() {
local mon="''${1}"
echo "''${MAP_ROOT}/''${mon}/defaults.conf"
}
ensure_map_file() {
local mon="''${1}"
local f
f="$(map_file_for_monitor "''${mon}")"
mkdir -p "$(dirname "''${f}")"
if [[ ! -f "''${f}" ]]; then
# Seed with 1..9 from picturesDir if present, else empty entries
{
for i in 1 2 3 4 5 6 7 8 9; do
seed="$(ls -1 "''${PICTURES_DIR}/''${i}."* 2>/dev/null | head -n 1 || true)"
echo "w-''${i}= ''${seed}"
done
} > "''${f}"
fi
echo "''${f}"
}
get_wall_for_ws() {
local mon="''${1}"
local wsid="''${2}"
local f key val
f="$(ensure_map_file "''${mon}")"
key="w-''${wsid}"
# accept "w-1=/path" or "w-1= /path"
val="$(awk -F= -v k="''${key}" '$1==k {sub(/^[[:space:]]+/, "", $2); print $2; exit}' "''${f}" || true)"
echo "''${val}"
}
apply_wallpaper() {
local mon="''${1}"
local wsid="''${2}"
local file
file="$(get_wall_for_ws "''${mon}" "''${wsid}")"
[[ -n "''${file}" ]] || return 0
[[ -f "''${file}" ]] || return 0
# Apply via IPC
# hyprpaper wallpaper { monitor path fit_mode } model is per monitor. :contentReference[oaicite:3]{index=3}
hyprctl hyprpaper wallpaper "''${mon}, ''${file}, ''${FIT_MODE}" >/dev/null
}
# Initial apply on startup
mon="$(focused_monitor || true)"
wsid="$(hyprctl -j activeworkspace | jq -r '.id' | head -n 1 || true)"
[[ -n "''${mon}" && -n "''${wsid}" ]] && apply_wallpaper "''${mon}" "''${wsid}"
handle() {
local line="''${1}"
case "''${line}" in
workspacev2* )
# workspacev2>>ID,NAME :contentReference[oaicite:4]{index=4}
local payload wsid
payload="''${line#*>>}"
wsid="''${payload%%,*}"
mon="$(focused_monitor || true)"
[[ -n "''${mon}" && -n "''${wsid}" ]] && apply_wallpaper "''${mon}" "''${wsid}"
;;
focusedmon* )
# focusedmon>>MON,WORKSPACENAME :contentReference[oaicite:5]{index=5}
# When monitor focus changes, re-apply for the active workspace id.
mon="$(focused_monitor || true)"
wsid="$(hyprctl -j activeworkspace | jq -r '.id' | head -n 1 || true)"
[[ -n "''${mon}" && -n "''${wsid}" ]] && apply_wallpaper "''${mon}" "''${wsid}"
;;
esac
}
socat -U - UNIX-CONNECT:"''${SOCK}" | while read -r line; do
handle "''${line}" || true
done
'';
backup = lib.mkForce false;
};
# CLI setter in the style of your inspiration script.
# Usage: set-wallpaper.sh <workspace_id> <monitor> [wallpaper]
xdg.configFile."${setRel}" = {
executable = true;
text = ''
#!/usr/bin/env bash
set -euo pipefail
executable = true;
text = lib.mkForce ''
#!/usr/bin/env bash
set -euo pipefail
HYPR_DIR="''${XDG_CONFIG_HOME:-$HOME/.config}/hypr"
MAP_ROOT="''${HYPR_DIR}/hyprpaper/config"
HYPR_DIR="''${XDG_CONFIG_HOME:-$HOME/.config}/hypr"
MAP_ROOT="''${HYPR_DIR}/hyprpaper/config"
usage() {
echo "Usage: set-wallpaper.sh <workspace_id> <monitor> [wallpaper_path]"
}
usage() {
echo "Usage: set-wallpaper.sh <workspace_id> <monitor> [wallpaper_path]"
}
wsid="''${1:-}"
mon="''${2:-}"
wp="''${3:-}"
wsid="''${1:-}"
mon="''${2:-}"
wp="''${3:-}"
[[ -n "''${wsid}" ]] || { usage; exit 1; }
[[ -n "''${mon}" ]] || { usage; exit 1; }
[[ -n "''${wsid}" ]] || { usage; exit 1; }
[[ -n "''${mon}" ]] || { usage; exit 1; }
cfg="''${MAP_ROOT}/''${mon}/defaults.conf"
mkdir -p "$(dirname "''${cfg}")"
[[ -f "''${cfg}" ]] || touch "''${cfg}"
cfg="''${MAP_ROOT}/''${mon}/defaults.conf"
mkdir -p "$(dirname "''${cfg}")"
[[ -f "''${cfg}" ]] || touch "''${cfg}"
if [[ -z "''${wp}" ]]; then
# Random pick from your defaults folder if you want; adjust path if needed:
wp="$(find "$HOME/.config/wallpapers/defaults" -type f 2>/dev/null | shuf -n 1 || true)"
[[ -n "''${wp}" ]] || { echo "No wallpaper found (random). Provide a path as arg 3."; exit 1; }
fi
if [[ -z "''${wp}" ]]; then
# Random pick from your defaults folder if you want; adjust path if needed:
wp="$(find "$HOME/.config/wallpapers/defaults" -type f 2>/dev/null | shuf -n 1 || true)"
[[ -n "''${wp}" ]] || { echo "No wallpaper found (random). Provide a path as arg 3."; exit 1; }
fi
# Ensure key exists; if not, append it
key="w-''${wsid}"
if ! grep -q "^''${key}=" "''${cfg}"; then
echo "''${key}=" >> "''${cfg}"
fi
# Ensure key exists; if not, append it
key="w-''${wsid}"
if ! grep -q "^''${key}=" "''${cfg}"; then
echo "''${key}=" >> "''${cfg}"
fi
# Set mapping
${pkgs.gnused}/bin/sed -i "s|^''${key}=.*|''${key}= ''${wp}|g" "''${cfg}"
# Set mapping
${pkgs.gnused}/bin/sed -i "s|^''${key}=.*|''${key}= ''${wp}|g" "''${cfg}"
# If this monitor is currently showing that workspace id, apply immediately
curws="$(hyprctl -j monitors | jq -r --arg m "''${mon}" '.[] | select(.name==$m) | .activeWorkspace.id' | head -n 1 || true)"
if [[ "''${curws}" == "''${wsid}" ]]; then
hyprctl hyprpaper wallpaper "''${mon}, ''${wp}, fill" >/dev/null
fi
'';
# If this monitor is currently showing that workspace id, apply immediately
curws="$(hyprctl -j monitors | jq -r --arg m "''${mon}" '.[] | select(.name==$m) | .activeWorkspace.id' | head -n 1 || true)"
if [[ "''${curws}" == "''${wsid}" ]]; then
hyprctl hyprpaper wallpaper "''${mon}, ''${wp}, fill" >/dev/null
fi
'';
backup = lib.mkForce false;
};
# Services
systemd.user.services.hyprpaper = {
Unit = {
Description = "hyprpaper wallpaper daemon";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
};
Service = {
ExecStart = "${pkgs.hyprpaper}/bin/hyprpaper";
Restart = "on-failure";
RestartSec = 1;
};
Install = { WantedBy = [ "graphical-session.target" ]; };
Unit = {
Description = "hyprpaper wallpaper daemon";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
};
Service = {
ExecStart = "${pkgs.hyprpaper}/bin/hyprpaper";
Restart = "on-failure";
RestartSec = 1;
};
Install = { WantedBy = [ "graphical-session.target" ]; };
};
systemd.user.services.hyprpaper-ws-daemon = {
Unit = {
Description = "Workspace->wallpaper mapping daemon (hyprpaper + socket2)";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" "hyprpaper.service" ];
};
Service = {
ExecStart = "${pkgs.bash}/bin/bash ${config.xdg.configHome}/${daemonRel} ${picturesDir}";
Restart = "on-failure";
RestartSec = 1;
};
Install = { WantedBy = [ "graphical-session.target" ]; };
Unit = {
Description = "Workspace->wallpaper mapping daemon (hyprpaper + socket2)";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" "hyprpaper.service" ];
};
Service = {
ExecStart = "${pkgs.bash}/bin/bash ${config.xdg.configHome}/${daemonRel} ${picturesDir}";
Restart = "on-failure";
RestartSec = 1;
};
Install = { WantedBy = [ "graphical-session.target" ]; };
};
}