1

I would like to download several images (from a server with a self-signed certificate) and view them all with feh. Is this possible with a single command? Something like curl -sk -b path_to_session_token url1 url2 | feh - - except this only feeds feh one of the files. Preferably without saving to a file and deleting it afterwards.

1 Answer 1

2

feh will not be able to distinguish between several images sent on its standard input, unless some kind of "protocol" is implemented.

If you don't want to use temporary files, you could maybe use a loop:

for url in 'url1' 'url2'; do
    curl -skb token "$url" | feh -
done

This will download and display each image one after the other. If you'd rather have several viewers opened at the "same time", add a little ampersand to it:

for url in 'url1' 'url2'; do
    (curl -skb token "$url" | feh - &)
done

Note that you can put everything on a single line, or maybe define a function:

$ for url in 'url1' 'url2'; do curl -skb token "$url" | feh -; done
$ for url in 'url1' 'url2'; do (curl -skb token "$url" | feh - &); done

function feh_urls
{
    for url; do
        curl -skb token "$url" | feh -
    done
}

$ feh_urls 'url1' 'url2'

Be careful with your quotes, as there may be some annoying spaces in your URLs or paths (... and I hope I didn't make such a mistake in the above examples...). If you go for a function, maybe add it to your .bashrc so you can use it in your shell without redefining it manually everytime.

For the sake of completeness, here is a little script (which could be made a function of course) involving some temporary files, saving a few curl and feh processes on the way. I am using wget instead of curl because depending on your version, you might not be able to grab remote filenames properly (you could give your images different names of course).

#!/bin/bash

img_dir=$(mktemp -d)
cd $img_dir
wget -q --no-check-certificate --load-cookie token "$@"
feh $img_dir/*
rm -r $img_dir

Usage:

$ ./feh_urls.sh 'url1' 'url2'

Note that the advantage here is that feh doesn't get spawned several times, and can load all the images at once (use the arrow keys to browse them).

You might also be interested in this page if you want more information about cookie management with wget, or this page for details about the SSL/TLS options.

1
  • Very elaborate, I'm certainly grateful for the effort. I suppose my dream scenario isn't possible with feh as it is (single feh spawn, no tmp files), so it looks like I'm going for tmp files. Thanks again! Commented Sep 25, 2015 at 5:47

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.