Edit download directory and viewer at top of script. Deletes image when program closes.
I run this from a tray icon with my text browser. When I want to view an image, I download and click on the icon. (Links browser downloads with "I" <return>).
Code: Select all
#!/bin/sh
## view/delete current downloaded image file
## for use with text browser
## edit: working directory
DESK="/mnt/sda2/Desktop"
## edit: viewer
VW="viewnior"
[ -f /tmp/jpgs ] && rm /tmp/jpgs
cd "$DESK"
DAY="$(date +%d)"
ls -l | egrep '(\.jpg|\.gif|\.png|\.bmp|\.tiff)' >>/tmp/jpgs
while read line; do
JPG="$(echo $line | cut -d' ' -f8-)"
JDAY="$(echo $line | cut -d' ' -f6- | cut -d\- -f3 | cut -d' ' -f1)"
[ "$JDAY" == "$DAY" ] && "$VW" "$JPG" && VAR=$JPG
done < /tmp/jpgs
sleep 1
wait
[ "$VAR" ] && rm "$VAR"
[ -f /tmp/jpgs ] && rm /tmp/jpgs