This simple script does the following when executed:
- executes
scrot
to draw a rectangle on the screen and save a PNG image - uploads this image to a custom server or to imgur.com
- copies the image URL on the server to the clipboard
- notifies the user that everything is done
If a keyboard shortcut is used to call this script, I call this easy screenshot sharing for X.
You need all the following:
- eepp's version of
scrot
if you want to support the-r
option, which makes it possible to resize/move the drawn rectangle; otherwise, the upstream version is fine, just remove the-r
option in the script curl
packagelibnotify
package (fornotify-send
)xsel
package (for copying to clipboard)
ss
sources ~/.ssrc
. This file must define two variables:
url
: the endpointcurl
will accesspassword
: your password for uploading images
Here's an example:
url="http://example.com/ss/up"
password="peanut-butter"
The endpoint must accept a POST request with the following variables:
img
: PNG image datapasswd
: plain text password
The response body must be the full URL of the stored image.
ss
sources ~/.ssrc
. This file must define the API key variable:
imgur_api_key
: a valid imgur API key
Here's an example:
imgur_api_key=b3625162d3418ac51a9ee805b1840452
When calling ss
, use the --imgur
option.
Add this to your ~/.fluxbox/keys
:
180 :exec /path/to/ss
Replace 180
by the keycode or key combination of your choice.
Add this to your ~/.i3/config
:
bindsym $mod+c exec sleep 0.2 && bash /path/to/ss
Replace $mod+c
by the key combination of your choice.
(It seems that sleeping is necessary here in order to use scrot
with
rectangle selection from an i3 key binding. Any fix is welcome.)