diff --git a/modules/home.nix b/modules/home.nix index f8af0a9..b51a09f 100644 --- a/modules/home.nix +++ b/modules/home.nix @@ -614,6 +614,8 @@ in # the ~/.local/share/bg symlink if it exists. "awww-daemon" "sh -c '[ -e \"$HOME/.local/share/bg\" ] && awww img \"$HOME/.local/share/bg\"'" + # re-push the wallpaper onto monitors connected after login (media.nix) + "wallpaper-hotplug" ]; }; }; diff --git a/modules/media.nix b/modules/media.nix index 726cd31..b29de0c 100644 --- a/modules/media.nix +++ b/modules/media.nix @@ -17,6 +17,22 @@ let [ -n "$1" ] && ln -sf "$(readlink -f "$1")" "$bgloc" ${pkgs.awww}/bin/awww img "$bgloc" ''; + + # awww-daemon paints only the outputs present when `awww img` last ran and does + # not repaint a monitor hotplugged afterwards — it comes up on the fill color + # (black), and a transparent foot on it then shows that black, not the + # wallpaper. Watch Hyprland's event socket and re-push the wallpaper (setbg + # with no arg → all current outputs) on each monitor-add. Hyprland emits both + # `monitoradded` and `monitoraddedv2`; match only the former so setbg fires + # once. Runs as a Hyprland exec-once (see home.nix). + wallpaperHotplug = pkgs.writeShellScriptBin "wallpaper-hotplug" '' + sock="''${XDG_RUNTIME_DIR}/hypr/''${HYPRLAND_INSTANCE_SIGNATURE}/.socket2.sock" + ${pkgs.socat}/bin/socat -u UNIX-CONNECT:"$sock" - | while IFS= read -r line; do + case "$line" in + "monitoradded>>"*) setbg ;; + esac + done + ''; in { programs.mpv = { @@ -50,6 +66,7 @@ in home.packages = with pkgs; [ setbg + wallpaperHotplug # re-push wallpaper to a hotplugged monitor (see comment above) awww # wayland wallpaper daemon (setbg backend) wl-clipboard # wl-copy, for the yank binds imagemagick # `magick`: rotate/flip binds