shortcut to get and copy the image URL to the clipboard?

Asked by vinicius veo on 2020-05-15

is there a shortcut to get and copy the image URL to the clipboard? (for sharing)

Question information

Language:
English Edit question
Status:
Answered
For:
Variety Edit question
Assignee:
No assignee Edit question
Last query:
2020-05-15
Last reply:
2020-05-31
Launchpad Janitor (janitor) said : #1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Peter Levi (peterlevi) said : #2

We don' t have one. But some additional tools and some light scripting can get us there:

First, you need xclip to work with the clipboard, and these two aliases:
$ cat ~/.bash_aliases | grep clip
alias setclip="xclip -selection c"
alias getclip="xclip -selection c -o"

Then "variety --get 2>/dev/null" gives you the path to the current wallpaper, silencing the message about Variety already running (which goes to stderr).
We can then use exiftool to read the ImageURL saved as EXIF metadata in the image, and we'll request it in json format.
We'll then use jq to get the ImageURL, strip the quotes using tr and then pass the result to setclip.

$ exiftool -j `variety --get 2>/dev/null` | jq '.[0].ImageURL' | tr -d '"' | setclip
$ getclip
https://w.wallhaven.cc/full/4v/wallhaven-4v62rl.png

Now you can use your global shortcut settings (in Ubuntu this would be Settings -> Keyboard) to add a shortcut for this command.

Can you help with this problem?

Provide an answer of your own, or ask vinicius veo for more information if necessary.

To post a message you must log in.