Everybody takes a desktop screenshot at some point. For whatever reason. In the true spirit of computer geeks I spent
two three hours writing and testing a shell script that will take a screenshot of your Linux desktop, upload the screenshot to the Internet via Dropbox and pop the URL into your clipboard for instant pasting without any interaction on your part.
To save you the thirty-or-so seconds it would take to do this by hand.
First off, install Dropbox if you don’t already have it. You can grab it via the link above. Or the link below (daddy wants his referrals). This script relies on two other CLI programs that you may or may not have installed:
xclip. A very easy way to see if you have them is to open a shell and type in:
whereis scrot && whereis xclip. If you do not have them, check your distribution’s repositories for the two programs. They are small and ubiquitous like leprechauns during the summer months:
Grab my screenie script here, and then
chmod +x the script to make it executable.
Third: IMPORTANT! After this you must open the script up in a text editor and modify the the
$DBUSER variable to match your Dropbox UID:
You can find your Dropbox UID very easily from within your Dropbox folder or from on the Dropbox website. Navigate to your Public folder, right-click on any file and select “copy public URL” from the menu of options. Part of this URL is a numerical string. Replace
CHANGEME with this string. As an example, my UID in the below URL for the script is “4144919”:
With all of those two, involved steps taken care of, you can run
screenie locally or install it (as root) into your
/usr/local/bin or equivalent folder for easy use.
# Change DBUSER to match your Dropbox UID. For more instructions, see above. DBUSER=CHANGEME TIME=$(date +%Y%m%d%H%M%S) PUB=~/Dropbox/Public/screenshots/ if [ -d $PUB ] then cd $PUB else mkdir $PUB cd $PUB fi sleep 1 scrot -d 5 -q 100 $TIME.jpg sleep 1 LAST=$(find . -cmin -1 -iname "*.jpg" | tail -n 1 | sed 's!.*/!!') URL1=https://ix.bhalash.com/u URL2=screenshots echo "$URL1/$DBUSER/$URL2/$LAST" | xclip -sel clip exit 0
If you are using Openbox you can take your laziness one step further by binding screenie to a keyboard shortcut. Push print screen. Twenty seconds later you have a smoldering hot URL in your clipboard yearning to be posted. Open up Openbox’s
rc.xml file, usually to be found residing in
~/.config/openbox/, and add the following lines to the pertinent section:
<keybind key="Print"> <action name="Execute"> <execute>screenie</execute> </action> </keybind>