Author Topic: scrot upload thumbnail and bbcode ready to paste, one script  (Read 2372 times)


  • Techno Hippie
  • Posts: 298
  • savant (alegedly), polymath (wannabe)
    • View Profile
scrot upload thumbnail and bbcode ready to paste, one script
« on: October 04, 2013, 08:44:16 PM »
as promised.

a script that will take a screenshot, upload it, with a thumbnail, and put the bbcode in your clipboard, ready to paste into your forum post with a simple middle click (or, shift insert i think should work too). 

i call it "xrt"

 ~note to self, get that echo  of the bbcode tee'd so peeps can re-copy it from terminal... presuming they ran it in terminal.

please note that as-is, this needs you to edit in your own dir locations, and for you to have write access to a server to upload it to... er, or cloudspace or whatever other fangledness, so long as you can have that location be mounted to a dir on your local fs.   or whatever other expanded hackings you do to this.  ;)

at a minimum, you likely just need to 
Code: [Select]
#! /bin/bash
#please read and configure this script for your own use

#set your local screenshot directory location
#e.g. LOCSCROT=~/images/screenshots

#set your uploads directory location, where you have your public scrots dir mounted in your local filesystem
#e.g. UP=/media/myserver/scrots

#set your sharable public url of where you uploaded.
#e.g. DOWN=  #which, btw, is an awesome url for a foss scrots site.

#well its bound to be a .png, right?  best leave this alone.
#e.g SUFFIX=".png"

#cos, u dont wanna over-write, right? n u wanna look back n know when, right?
#e.g.TIMESTAMP=$(date +%Y%m%d%H%M)
TIMESTAMP=$(date +%Y%m%d%H%M)

#image name (before the date)
#e.g. PIC="screenshot"

##optional additional after the date
##not yet implemented ~ but feel free to manually meddle

#so now you have the parts, you can rearange the names of your full image, and thumbnail here:
#so now the full image will be called:
#and a thumbnail of it will be called:

echo -n "taking screenshot"
scrot -e 'mv $f tmp.png'

echo " screenshot"
mv tmp.png $LOCSCROT/$FULL

echo "creating thumbnail on server"
convert             \
   $LOCSCROT/$FULL        \
  -format "png" \
  -resize 400x300     \
  -background white \
  -gravity center   \
  -extent 400X300     \

echo "uploading fullsize image to server"

#cp /home/digit/images/screenshots/xrt.png $UP/xrt-full.png
#cp /home/digit/images/screenshots/xrt.png $UP/xrt-$(date +%Ym%d%M%S).png

echo "making bbcode available, ready to paste (just middle click)"

#this then provides you with the bb code in your clipboard
echo "[url=$DOWN/$FULL][img]$DOWN/$THUMB[/img][/url]" | xclip

echo "ok to go"

er... i better just check that one more time...

looks good.