summaryrefslogtreecommitdiff
path: root/nixos/profiles/workstation/scripts/set-wallpaper
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2025-02-27 21:20:58 +0100
committerMartin Fischer <martin@push-f.com>2025-02-27 21:23:27 +0100
commit42374d30a16ca98d38ca3d73bdbd8abaaf662b3b (patch)
tree659f0935b5d77f40c9e6b9e3e47edaddb5031bcb /nixos/profiles/workstation/scripts/set-wallpaper
parentf52ef901cb6459a5fe7446fe6e69eab82cb373eb (diff)
feat(workstation): generate wallpaper from roadmap.md
Diffstat (limited to 'nixos/profiles/workstation/scripts/set-wallpaper')
-rw-r--r--nixos/profiles/workstation/scripts/set-wallpaper20
1 files changed, 20 insertions, 0 deletions
diff --git a/nixos/profiles/workstation/scripts/set-wallpaper b/nixos/profiles/workstation/scripts/set-wallpaper
new file mode 100644
index 0000000..2bfdf0d
--- /dev/null
+++ b/nixos/profiles/workstation/scripts/set-wallpaper
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+# Sets the text read from stdin as the Sway wallpaper.
+
+TEXT=$(< /dev/stdin)
+TEMPDIR=$(mktemp -d)
+FONT_SIZE=18
+
+swaymsg -t get_outputs | jq -r '.[] | "\(.name) \(.rect.width) \(.rect.height)"'\
+| while read -r name width height; do
+ file="$TEMPDIR/${name}".png
+ offset=$(($height / 20))
+ width=$(($width - $offset))
+ height=$(($height - $offset))
+ magick -size ${width}x$height xc:black -font "DejaVu-Sans-Mono" -pointsize $FONT_SIZE -fill white \
+ -annotate +0+15 "$TEXT" $file
+ sway output "$name" bg $file center
+done
+
+sleep 0.1 # sway reads the wallpaper in a different process, so wait a bit
+rm -r "$TEMPDIR"