Easy Screenshots in Linux

1 minute read Published:

Here is a small script to make it easy to take screenshots and send them to my webserver for sharing.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash

# Create a temporary file to store the screenshot in
tmpfile=$(mktemp /tmp/XXXXXXX.png)

# Take the screenshot
scrot -s "$tmpfile" > /dev/null

# Copy the file to the server
scp "$tmpfile" webserver:/var/www/screenshots.example.com > /dev/null

# Generate the url for the screenshot
url=https://screenshots.example.com/$(basename "$tmpfile")

# Output url, open the url in the browser, and copy url to clipboard
echo "$url" | xclip
xdg-open "$url" &> /dev/null
echo "$url"

# Remove the screenshot
rm "$tmpfile"