You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
3.4 KiB
105 lines
3.4 KiB
#!/usr/bin/env fish
|
|
|
|
# Configuration
|
|
set WALLPAPER_DIR "/mnt/linux-files-2/Pictures/hevin"
|
|
set CYCLE_TIME 5 # Seconds between image changes
|
|
#set BLUR_AMOUNT "0x5" # Set to "0x0" for no blur
|
|
set BLUR_AMOUNT "0x0" # Set to "0x0" for no blur
|
|
|
|
# Get monitor information - use exact names from xrandr
|
|
set monitors (xrandr --query | grep " connected" | awk '{print $1}')
|
|
set geometries (xrandr --query | grep -A1 " connected" | grep -v " connected" | awk '{print $1}')
|
|
|
|
# Verify we found monitors
|
|
if test (count $monitors) -eq 0
|
|
echo "Error: No monitors detected!"
|
|
exit 1
|
|
end
|
|
|
|
# Create monitor geometry mapping
|
|
set -g monitor_geometries
|
|
for i in (seq (count $monitors))
|
|
set monitor $monitors[$i]
|
|
set geo $geometries[$i]
|
|
if test -z "$geo"
|
|
echo "Warning: Could not get geometry for monitor $monitor, using default 1920x1080"
|
|
set geo "1920x1080"
|
|
end
|
|
set monitor_geometries $monitor_geometries "$monitor:$geo"
|
|
end
|
|
|
|
# Function to restore monitor layout
|
|
function restore_monitors
|
|
xrandr --auto
|
|
xrandr --output HDMI-0 --right-of DVI-I-1
|
|
end
|
|
|
|
# Trap to restore monitors on exit
|
|
trap restore_monitors EXIT
|
|
|
|
while true
|
|
# Use only the first monitor's geometry
|
|
set entry $monitor_geometries[1]
|
|
set primary_monitor (echo $entry | cut -d':' -f1)
|
|
set geo (echo $entry | cut -d':' -f2)
|
|
set width (echo $geo | cut -d'x' -f1)
|
|
set height (echo $geo | cut -d'x' -f2)
|
|
|
|
# Turn off all other monitors
|
|
for monitor in $monitors
|
|
if test "$monitor" != "$primary_monitor"
|
|
xrandr --output $monitor --off 2>/dev/null || echo "Warning: Could not turn off monitor $monitor"
|
|
end
|
|
end
|
|
|
|
# Select and process image
|
|
set image (fdfind -e jpg -e jpeg -e png -e webp . $WALLPAPER_DIR | shuf -n 1)
|
|
if test -n "$image"
|
|
echo "Found image: $image"
|
|
|
|
# Get image dimensions
|
|
set img_info (identify -format "%wx%h" "$image")
|
|
set img_width (echo $img_info | cut -d'x' -f1)
|
|
set img_height (echo $img_info | cut -d'x' -f2)
|
|
|
|
# Process image based on orientation
|
|
if test $img_height -gt $img_width
|
|
# Vertical image - fit to height with black background
|
|
convert "$image" \
|
|
-resize x{$height}^ \
|
|
-gravity center \
|
|
-background black \
|
|
-extent {$width}x{$height} \
|
|
-blur $BLUR_AMOUNT \
|
|
"/tmp/screensaver-$primary_monitor.png"
|
|
else
|
|
# Horizontal image - fit to width
|
|
convert "$image" \
|
|
-resize {$width}x^ \
|
|
-gravity center \
|
|
-extent {$width}x{$height} \
|
|
-blur $BLUR_AMOUNT \
|
|
"/tmp/screensaver-$primary_monitor.png"
|
|
end
|
|
|
|
# Display image on single monitor
|
|
feh --no-fehbg --hide-pointer --fullscreen --title 'screensaver' "/tmp/screensaver-$primary_monitor.png" &
|
|
set feh_pid $last_pid
|
|
|
|
# Wait for cycle time
|
|
sleep $CYCLE_TIME
|
|
|
|
# Kill feh process
|
|
kill $feh_pid 2>/dev/null
|
|
|
|
# Turn other monitors back on
|
|
for monitor in $monitors
|
|
if test "$monitor" != "$primary_monitor"
|
|
xrandr --output $monitor --auto 2>/dev/null || echo "Warning: Could not turn on monitor $monitor"
|
|
end
|
|
end
|
|
else
|
|
echo "Error: No images found in $WALLPAPER_DIR"
|
|
exit 1
|
|
end
|
|
end
|