blob: 812c0f6cde24da4511ec0009e480467a8614a081 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/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"
|