implementing home.file instead of xdg.config
This commit is contained in:
+319
-531
File diff suppressed because it is too large
Load Diff
+2
-209
@@ -564,8 +564,7 @@ The tree below shows the full repository layout, with the standardized internal
|
||||
│ │ ├── powermenu.nix
|
||||
│ │ ├── rotating_wallpaper.nix
|
||||
│ │ ├── walker.nix
|
||||
│ │ ├── waybar.nix
|
||||
│ │ └── workspace_wallpaper.nix
|
||||
│ │ └── waybar.nix
|
||||
│ └── dev
|
||||
│ ├── alacritty.nix
|
||||
│ ├── dev.nix
|
||||
@@ -1617,8 +1616,7 @@ This module will import all necessities.
|
||||
./desktop/ncsway.nix
|
||||
./desktop/powermenu.nix
|
||||
#./desktop/animated_wallpaper.nix
|
||||
#./desktop/rotating_wallpaper.nix
|
||||
./desktop/workspace_wallpaper.nix
|
||||
./desktop/rotating_wallpaper.nix
|
||||
./desktop/waybar.nix
|
||||
./desktop/walker.nix
|
||||
./dev/dev.nix
|
||||
@@ -1767,211 +1765,6 @@ in
|
||||
}
|
||||
#+end_src
|
||||
|
||||
** Workspace Wallpaper
|
||||
#+begin_src nix :tangle home/desktop/workspace_wallpaper.nix :noweb tangle :mkdirp yes
|
||||
{ config, lib, pkgs, flakeRoot, ... }:
|
||||
|
||||
let
|
||||
userRelRoot = "nixos_conf/wallpaperstuff";
|
||||
userAbsRoot = "${config.home.homeDirectory}/${userRelRoot}";
|
||||
picturesDir = "${userAbsRoot}/pictures";
|
||||
repoWallpaperDir = flakeRoot.outPath + "/assets/conf/desktop/wallpaper";
|
||||
repoWallpapersOnly = lib.cleanSourceWith {
|
||||
src = repoWallpaperDir;
|
||||
filter = path: type: true;
|
||||
};
|
||||
daemonRel = ".config/hypr/scripts/hyprpaper-ws-daemon.sh";
|
||||
setRel = ".config/hypr/scripts/set-wallpaper.sh";
|
||||
in
|
||||
{
|
||||
home.packages = [
|
||||
pkgs.hyprpaper
|
||||
pkgs.socat
|
||||
pkgs.jq
|
||||
pkgs.findutils
|
||||
pkgs.coreutils
|
||||
pkgs.gnused
|
||||
pkgs.gawk
|
||||
];
|
||||
|
||||
# Sync wallpapers into a writable directory
|
||||
home.file."${userRelRoot}" = {
|
||||
source = repoWallpapersOnly;
|
||||
recursive = true;
|
||||
};
|
||||
|
||||
# Hyprpaper config
|
||||
home.file.".config/hypr/hyprpaper.conf" = {
|
||||
text = ''
|
||||
ipc = true
|
||||
splash = false
|
||||
'';
|
||||
};
|
||||
|
||||
# Workspace wallpaper daemon
|
||||
home.file."${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}}" # $1 = eerste argument, ${picturesDir} = default (Bash-variabele)
|
||||
FIT_MODE="fill"
|
||||
HYPR_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/hypr" # Gebruik $HOME als fallback
|
||||
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
|
||||
{
|
||||
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}"
|
||||
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
|
||||
hyprctl hyprpaper wallpaper "$mon, $file, $FIT_MODE" >/dev/null
|
||||
}
|
||||
|
||||
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* )
|
||||
payload="${line#*>>}"
|
||||
wsid="${payload%%,*}"
|
||||
mon="$(focused_monitor || true)"
|
||||
[[ -n "$mon" && -n "$wsid" ]] && apply_wallpaper "$mon" "$wsid"
|
||||
;;
|
||||
focusedmon* )
|
||||
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
|
||||
'';
|
||||
};
|
||||
|
||||
# CLI setter
|
||||
home.file."${setRel}" = {
|
||||
executable = true;
|
||||
text = ''
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
HYPR_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/hypr"
|
||||
MAP_ROOT="${HYPR_DIR}/hyprpaper/config"
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 <workspace_id> <monitor> [wallpaper_path]"
|
||||
}
|
||||
|
||||
wsid="${1:-}"
|
||||
mon="${2:-}"
|
||||
wp="${3:-}"
|
||||
|
||||
[[ -n "$wsid" ]] || { usage; exit 1; }
|
||||
[[ -n "$mon" ]] || { usage; exit 1; }
|
||||
|
||||
cfg="${MAP_ROOT}/${mon}/defaults.conf"
|
||||
mkdir -p "$(dirname "$cfg")"
|
||||
[[ -f "$cfg" ]] || touch "$cfg"
|
||||
|
||||
if [[ -z "$wp" ]]; then
|
||||
wp="$(find "${XDG_CONFIG_HOME:-$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
|
||||
|
||||
key="w-${wsid}"
|
||||
if ! grep -q "^${key}=" "$cfg"; then
|
||||
echo "${key}=" >> "$cfg"
|
||||
fi
|
||||
|
||||
sed -i "s|^${key}=.*|${key}= ${wp}|g" "$cfg"
|
||||
|
||||
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
|
||||
'';
|
||||
};
|
||||
|
||||
# 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" ]; };
|
||||
};
|
||||
|
||||
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.home.homeDirectory}/${daemonRel} ${picturesDir}";
|
||||
Restart = "on-failure";
|
||||
RestartSec = 1;
|
||||
};
|
||||
Install = { WantedBy = [ "graphical-session.target" ]; };
|
||||
};
|
||||
}
|
||||
#+end_src
|
||||
|
||||
** Waybar
|
||||
[[./.github/images/waybar.png]]
|
||||
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
./desktop/ncsway.nix
|
||||
./desktop/powermenu.nix
|
||||
#./desktop/animated_wallpaper.nix
|
||||
#./desktop/rotating_wallpaper.nix
|
||||
./desktop/workspace_wallpaper.nix
|
||||
./desktop/rotating_wallpaper.nix
|
||||
./desktop/waybar.nix
|
||||
./desktop/walker.nix
|
||||
./dev/dev.nix
|
||||
|
||||
Reference in New Issue
Block a user