Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions modules/link/wallpaper.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
_:
let
main = builtins.fetchurl {
name = "wallpaper-14nh77xn8x58693y2na5askm6612xqbll2kr6237y8pjr1jc24xp.png";
url = "https://drive.usercontent.google.com/download?id=1OrRpU17DU78sIh--SNOVI6sl4BxE06Zi";
sha256 = "14nh77xn8x58693y2na5askm6612xqbll2kr6237y8pjr1jc24xp";
};
side = builtins.fetchurl {
name = "wallpaper-05jbbil1zk8pj09y52yhmn5b2np2fqnd4jwx49zw1h7pfyr7zsc8.png";
url = "https://blusky.s3.us-west-2.amazonaws.com/SU_SKY.PNG";
sha256 = "05jbbil1zk8pj09y52yhmn5b2np2fqnd4jwx49zw1h7pfyr7zsc8";
};
in
{
configurations.nixos.link.module =
{ pkgs, config, ... }:
let
set-wallpaper = pkgs.writeShellApplication {
name = "set-wallpaper";
runtimeInputs = [
pkgs.swww
pkgs.socat
pkgs.jq
config.programs.hyprland.package
];
text = ''
# Wait for swww daemon to be ready
until swww query &>/dev/null; do sleep 0.5; done

# Set wallpapers on known monitors (|| true so a missing output doesn't abort)
swww img --outputs DP-1 "${main}" || true
swww img --outputs DP-3 "${side}" || true

# Resolve the active Hyprland socket
XDG_RUNTIME_DIR="''${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
sig=$(hyprctl instances -j | jq -r 'sort_by(.time) | last | .instance')
socket="$XDG_RUNTIME_DIR/hypr/$sig/.socket2.sock"

# Watch for new monitors and apply the default wallpaper
socat -u "UNIX-CONNECT:$socket" - | while IFS= read -r line; do
case "$line" in
monitoradded*)
monitor="''${line#monitoradded>>}"
swww img --outputs "$monitor" "${main}"
;;
esac
done
'';
};
in
{
home-manager.users.tunnel =
{ lib, ... }:
{
systemd.user.services.wallpaper = {
Unit = {
Description = "Set wallpaper on all monitors and watch for new ones";
After = [
"swww.service"
"graphical-session.target"
];
PartOf = [ "graphical-session.target" ];
};
Service = {
ExecStart = lib.getExe set-wallpaper;
Restart = "on-failure";
RestartSec = "3s";
};
Install.WantedBy = [ "graphical-session.target" ];
};
};
};
}
Loading