Ubuntu 17.10 ships with Wayland by default. This breaks the default behaviour of many applications which worked fine with Xorg. One of these application is Shutter which people could use to take screenshots and upload to Dropbox (something I do frequently to share screenshots over Slack with team members).

Not wanting to switch to Xorg, I needed a convenient solution to do the following:

  • take screenshots of an area on my screen
  • have the screenshot uploaded to my Dropbox account
  • copy the sharing link of that file to my clipboard

The following script helped me do the above, after ensuring I had xclip and Dropbox installed.

#!/bin/bash

function take-area-screenshot-and-upload-to-dropbox {
  local screenshot_file_path="$HOME/Dropbox/Public/Screenshots/screenshot_`date +'%F_%T' | tr : -`.png"
  mkdir -p `dirname $screenshot_file_path`
  gnome-screenshot -a -p -f $screenshot_file_path
  sleep 0.3
  local link=$(dropbox sharelink $screenshot_file_path)
  echo $link | xclip -selection c
  echo "Copied $link to clipboard."
  return 0
}

take-area-screenshot-and-upload-to-dropbox

I put that in a ~/.screenshot_capture_and_upload.sh file and setup a custom shortcut for it (in Settings -> Keyboard). The shortcut was Ctr + Shift + R and using it executes bash ~/.screenshot_capture_and_upload.sh. The cursor changes, I take the screenshot, and paste the sharing link of the file anywhere since it’s already copied to the clipboard.

Additionally, if you’d like to add a border to your screenshots, you can add the following line to your script after the gnome-screenshot command and before the sleep command. You can change the HEX code to match the color of the border you would like.

convert -border 2x2 -bordercolor "#1F30B8" $screenshot_file_path $screenshot_file_path