#!/bin/bash # Find a random image file #IMAGE=$(find /run/media/raga/970/qBittorrent/nsfw/xd -type f \( -name '*.png' -o -name '*.jpg' -o -name '*.jpeg' \) | shuf -n 1) IMAGE=$(find /run/media/raga/970/images/cars/wallpaper -type f \( -name '*.png' -o -name '*.jpg' -o -name '*.jpeg' \) | shuf -n 1) if [ -n "$IMAGE" ]; then echo "Image: $IMAGE" # Try to get image dimensions using identify (ImageMagick) DIMENSIONS=$(identify -format "%wx%h" "$IMAGE" 2>/dev/null) if [ -n "$DIMENSIONS" ]; then echo "Dimensions: $DIMENSIONS" WIDTH=$(echo "$DIMENSIONS" | cut -d'x' -f1) HEIGHT=$(echo "$DIMENSIONS" | cut -d'x' -f2) # Determine if portrait (height > width) or landscape if [ "$HEIGHT" -gt "$WIDTH" ]; then # Portrait image - use "fit" to maintain aspect ratio echo "Portrait image - using fit" swaymsg "output * bg \"$IMAGE\" fit" else # Landscape image - use "fill" to fill the screen echo "Landscape image - using fill" swaymsg "output * bg \"$IMAGE\" fill" fi else # Fallback to fill if we can't determine dimensions echo "Could not determine dimensions - using fill" swaymsg "output * bg \"$IMAGE\" fill" fi fi