#!/bin/bash # Adapted from http://ubuntuforums.org/archive/index.pho/t-964558.html # which does not seem to exist anymore. WPDIR="$HOME/Pictures/wallpapers" AX=1920 AY=1200 BX=1680 BY=1050 CX=2560 CY=1440 DX=1920 DY=1080 TEMP_DIR=/run/user/$(id -u) ATEMP=$TEMP_DIR/dualbackgroundA.$$.$RANDOM BTEMP=$TEMP_DIR/dualbackgroundB.$$.$RANDOM CTEMP=$TEMP_DIR/dualbackgroundC.$$.$RANDOM DTEMP=$TEMP_DIR/dualbackgroundD.$$.$RANDOM files=( "$WPDIR/"* ) # From http://stackoverflow.com/questions/701505/ FIRST="${files[RANDOM % ${#files[@]}]}" SECOND="${files[RANDOM % ${#files[@]}]}" THIRD="${files[RANDOM % ${#files[@]}]}" FOURTH="${files[RANDOM % ${#files[@]}]}" # Resize images and store in temp directory convert "$FIRST" \ -resize x${AY} -resize "${AX}x<" \ -gravity center -crop ${AX}x${AY}+0+0 +repage "$ATEMP" convert "$SECOND" \ -resize x${BY} -resize "${BX}x<" \ -gravity center -crop ${BX}x${BY}+0+0 +repage "$BTEMP" convert "$THIRD" \ -resize x${CY} -resize "${CX}x<" \ -gravity center -crop ${CX}x${CY}+0+0 +repage "$CTEMP" convert "$FOURTH" \ -resize x${DY} -resize "${DX}x<" \ -gravity center -crop ${DX}x${DY}+0+0 +repage "$DTEMP" # Join images to output file montage "$ATEMP" "$BTEMP" "$CTEMP" "$DTEMP" -mode Concatenate -tile x1 -gravity north "$TEMP_DIR/final.jpg" # And have feh display them feh --no-xinerama --bg-center "$TEMP_DIR/final.jpg" # Remove temporary files from tmpfs and move the final result to /tmp rm "$ATEMP" rm "$BTEMP" rm "$CTEMP" rm "$DTEMP" cp "$TEMP_DIR/final.jpg" /tmp/ rm "$TEMP_DIR/final.jpg"