#!/bin/bash scale=5 DIR="$( readlink -f "$1" )" [[ -d "$DIR" ]] || { echo "NEED DIRECTORY NAME"; exit -1; } while true; do read -p "Enter resolution of pape (WxH, e.g. 1920x1080): " res [[ "$res" =~ [0-9]+x[0-9]+ ]] && break echo "Wrong input" done X=${res%x*} Y=${res#*x} [[ $X -eq 0 || $Y -eq 0 ]] && echo "Don't fuck around" && exit res=$( echo "scale = $scale; $X / $Y" | bc ) upper=$( echo "scale = $scale; $res + 0.05" | bc ) lower=$( echo "scale = $scale; $res - 0.05" | bc ) echo "$upper --- $lower" candidates="$( mktemp --tmpdir=$HOME/Desktop )" find "$DIR" -type f -iregex ".*\.\(bmp\|gif\|jpg\|jpeg\|png\)$" -print0 | while read -d $'\0' pic; do res=$( identify "$pic" | grep -o --extended-regexp --ignore-case "[0-9]+x[0-9]+" | head -1 | sed -r "s|x|\ / |; s|^|scale = $scale; |" | bc ) if (( $(echo "$upper >= $res" | bc -l) && $(echo "$lower <= $res" | bc -l) )); then echo "$pic" >> $candidates; fi done monitor="$( xfconf-query -c xfce4-desktop -l | grep "workspace0/last-image" | dmenu -l 5 )" feh --info "printf '%S %wx%h'" --zoom max --scale-down -g 1280x720 -B black -d --action1 "cp %F $HOME/Desktop" --action2 "nohup gimp -a %F >/dev/null 2>&1 &" --action3 "xfconf-query -c xfce4-desktop -p $monitor -s %F" -f "$candidates" rm "$candidates"