#!/usr/bin/env bash

# Initialize swww daemon if not running
if ! pgrep -x "swww-daemon" >/dev/null; then
	swww-daemon &
	sleep 1
fi

# Set wallpaper based on hostname
case "$(hostname)" in
"main")
	# Get all outputs and set random wallpapers with transitions
	swaymsg -t get_outputs -r | jq -r ".[].name" | while read -r output; do
		random_wallpaper=$(find ~/Pictures/* -type f | shuf -n 1)
		swww img "$random_wallpaper" --outputs "$output" --transition-type center --transition-step 120 --transition-fps 144 &
	done
	;;
"fw")
	# # Set specific wallpaper for fw host
	# swww img "$HOME/Pictures/hwtioswoamne1.jpeg" --transition-type center --transition-step 120 --transition-fps 144
	# ;;
	#
	# Get all outputs and set random wallpapers with transitions
	swaymsg -t get_outputs -r | jq -r ".[].name" | while read -r output; do
		random_wallpaper=$(find ~/Pictures/* -type f | shuf -n 1)
		swww img "$random_wallpaper" --outputs "$output" --transition-type center --transition-step 120 --transition-fps 144 &
	done
	;;
*)
	echo "Unknown hostname: $(hostname)"
	exit 1
	;;
esac

wait
