I'm writing a program that gets a bunch of images from Librex' API, then opens them in feh.

Here's the source:

args = sys.argv[1:]
for i in args:
    if "-" in i:
sch = quote("+".join(args).replace(" ", "+")).replace("%2B", "+")
sts = ["librex.extravi.dev", 
st = random.choice(sts)
def images(search, site):
    URL = f"https://{site}/api.php?q={search}&p=0&type=1"
    data = requests.get(url=URL).json()
    imgList = str()

    for i in data[:2]:
        imgList += f" {i['thumbnail']}"
    subprocess.Popen(["feh", imgList])
images(sch, st)

But when I run the final "feh" command with multiple options, I get an error message along the lines of feh WARNING: https://s1.qwant.com/thumbr/exmple1.jpg https://s2.qwant.com/thumbr/example2 does not exist - skipping

I've tried running feh alone with each link, so it isn't something wrong with the links. But then if I re run feh with all the links, I get the same error.

Is there a way to run feh with multiple URLs?

1 Answer 1


By using imgList+= you are actually concatenating the urls into one big string which you then pass as one argument to feh.

Change imgList to be a list (not a string) and then use imgList.append() to add thumbnails urls to it.

Then destructure your list so that you pass its contents as separate elements of the array provided to Popen, so that they are passed as separate arguments to feh.

subprocess.Popen(["feh", *imgList])

See how feh can indeed access 2 urls at the same time:

feh https://i.pinimg.com/236x/d3/fb/69/d3fb6973cddc1d875dc7c2e04525d2e7.jpg https://i.pinimg.com/236x/f4/dc/58/f4dc58f3bddf1c5b5249511820246df8.jpg

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .