From 0825408ddfe71336dff03ba5feae1760d6ab908a Mon Sep 17 00:00:00 2001 From: "s0wlz (Matthias Puchstein)" Date: Thu, 1 Jan 2026 18:30:50 +0100 Subject: [PATCH] swww: add systemd service and wallpaper setter --- .../symlink_swww.service | 1 + dot_config/systemd/user/swww.service | 14 +++++++++++ dot_local/bin/executable_set-wallpapers.tmpl | 25 +++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 dot_config/systemd/user/graphical-session.target.wants/symlink_swww.service create mode 100644 dot_config/systemd/user/swww.service create mode 100644 dot_local/bin/executable_set-wallpapers.tmpl diff --git a/dot_config/systemd/user/graphical-session.target.wants/symlink_swww.service b/dot_config/systemd/user/graphical-session.target.wants/symlink_swww.service new file mode 100644 index 0000000..423f115 --- /dev/null +++ b/dot_config/systemd/user/graphical-session.target.wants/symlink_swww.service @@ -0,0 +1 @@ +../swww.service diff --git a/dot_config/systemd/user/swww.service b/dot_config/systemd/user/swww.service new file mode 100644 index 0000000..198c105 --- /dev/null +++ b/dot_config/systemd/user/swww.service @@ -0,0 +1,14 @@ +[Unit] +Description=swww wallpaper daemon +PartOf=graphical-session.target +After=graphical-session.target + +[Service] +Type=simple +ExecStart=/usr/bin/swww-daemon +ExecStartPost=%h/.local/bin/set-wallpapers +Restart=on-failure +RestartSec=1 + +[Install] +WantedBy=graphical-session.target diff --git a/dot_local/bin/executable_set-wallpapers.tmpl b/dot_local/bin/executable_set-wallpapers.tmpl new file mode 100644 index 0000000..ea45d0c --- /dev/null +++ b/dot_local/bin/executable_set-wallpapers.tmpl @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -euo pipefail + +if ! command -v swww >/dev/null 2>&1; then + echo "swww not found in PATH" >&2 + exit 1 +fi + +for _ in {1..50}; do + if swww query >/dev/null 2>&1; then + break + fi + sleep 0.1 +done + +if ! swww query >/dev/null 2>&1; then + echo "swww-daemon not responding" >&2 + exit 1 +fi + +{{- range .monitors }} + {{- if .wallpaper }} +swww img -o {{ .name }} "{{ .wallpaper }}" + {{- end }} +{{- end }}