Monday, May 6, 2024
11
rated 0 times [  11] [ 0]  / answers: 1 / hits: 4594  / 1 Year ago, thu, march 16, 2023, 2:21:09

I don't like the GUI way of taking screenshot,uploading it to imgur and get the uploaded link.



So what can I do to take a screenshot of my Ubuntu desktop, upload the screenshot to imgur.com and then get back the uploaded link from terminal?



All I have to do from terminal.


More From » command-line

 Answers
5

Take the screenshot of your desktop



gnome-screenshot was the default command-line tool on Ubuntu to take a screenshot.



gnome-screenshot -d 10


Delayed the screenshot action by 10 seconds,So that you can place the desired window on front within 10 seconds.The taken images are actually stored in ~/Pictures folder.



Upload the image to imgur.com



gedit ~/.bashrc


Add the below lines to the opened .bashrc file and then save it.



imgur() {
for i in "$@"; do
curl -# -F "image"=@"$i" -F "key"="4907fcd89e761c6b07eeb8292d5a9b2a" imgur.com/api/upload.xml|
grep -Eo '<[a-z_]+>http[^<]+'|sed 's/^<.|_./U&/g;s/_/ /;s/<(.*)>/x1B[0;34m1:x1B[0m /'
done
}


Source the .bashrc file,so that the changes can take effect,



source ~/.bashrc


The above script requires curl package to work.So install it by running



sudo apt-get install curl


Then run the below command to upload the image stored in the ~/Pictures folder to imgur.com,



imgur ~/Pictures/filename.png


Get the link of uploaded image



enter image description here



Source


[#27110] Thursday, March 16, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
diffeah

Total Points: 78
Total Questions: 130
Total Answers: 98

Location: Peru
Member since Fri, Oct 14, 2022
2 Years ago
;