blob: 2bfdf0d33c55d6fffcca7cced51747b331fc8e6a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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"
|