#!/bin/sh
BACKS="/usr/share/backgrounds"

if [ -n "$WAYLAND_DISPLAY" ]; then
	swaymsg output '*' background "$(find "$BACKS" -type f | shuf -n 1)" fill
else
	find "/run/user/$(id -u)/" -name "sway-ipc*" \
		-exec swaymsg -s {} "exec $0" +
fi