Get image URL and open it with Gwenview/Gimp

My education is severely limited. I know this should be easy, but I’m scratching my head.

The issue:

I use Variety wallpaper changer, which has a command ‘variety --get’ which will get information about the current wallpaper:

variety --get                                                                  

Variety is already running. Sending the command to the running instance.
/home/ben/.config/variety/Downloaded/Unsplash/photo-1699656844811-ce67291ab27a.jpg

So I can send this output to a file (just the second line, not the first informational line):

variety --get > /temp/variety-get.txt

This gives me the <URL> as text.

What I actually want to do is launch gwenview <url> and/or GIMP <url>. This works in terminal…

I tried 'gimp < url.txt` but obviously it doesn’t read the file, it tries to open it.

Also piping variety --get | gimp doesn’t pass the URL to GIMP.

What am I missing here?

This would probably work;

variety --get > /tmp/variety-get.txt
_gimpimg=$(cat /tmp/variety-get.txt)
gimp "$_gimpimg"

And you might be able to simplify it to;

variety --get > /tmp/variety-get.txt
gimp $(cat /tmp/variety-get.txt)

Or even;

gimp $(variety --get)

Note: I have no idea about variety, but I do know gimp can be picky about paths. cat should work to print the file contents, and as long as those exist and are full (I dont believe ~ works) it should open that file in gimp. Of course you can also use flags like -a (as new), etc.

1 Like

An alternative solution might to make up a couple of scripts called something like “varietygwen” & “varietygimp”. That way you don’t have to type the text file path or anything to run it. I didn’t think of using cat to read the file, but use while/read for each line in the file. Here’s something I quickly wrote to open in gwenview:

 #!/bin/bash

variety --get > /tmp/variety-get.txt

while read -r line; do

gwenview "${line}"

done < /tmp/variety-get.txt

exit 0
1 Like

Superb - more gestures :wink:

Golden - I created a couple of scripts.

I should study more…

2 Likes

Same; I’ve never encountered hieroglyphics quite like that before.

1 Like

They’re firmly imprinted once I thought them up…

There was a conflict with setting volume at 10% which is like a ‘v’ with an ‘0’… so I opted for ‘variety explore’ to open gwenview, then a squiggly g to edit.

But it’s worth it - my latest edit:

1 Like

That scene actually looks familiar, for some reason; it reminds me of Amsterdam, but I don’t think it is.

It’s Switzerland - there are no hamsters in my blender!

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.