VSIDO Community

VSIDO Support => Scripts and How To's => Scripts => Topic started by: Digit on October 04, 2013, 08:44:16 PM

Title: scrot upload thumbnail and bbcode ready to paste, one script
Post by: Digit 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 
#! /bin/bash
#please read and configure this script for your own use

#set your local screenshot directory location
#e.g. LOCSCROT=~/images/screenshots
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
UP="/media/ovhtoo/home/digit/stuff/scrots"

#set your sharable public url of where you uploaded.
#e.g. DOWN=http://gnudistporn.tv/scrots  #which, btw, is an awesome url for a foss scrots site.
DOWN="http://ks392457.kimsufi.com/stuff/scrots"

#well its bound to be a .png, right?  best leave this alone.
#e.g SUFFIX=".png"
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"
PIC="xrt"

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

#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:
#e.g. FULL=$PIC$TIMESTAMP$EXTRA$SUFFIX
FULL=$PIC$TIMESTAMP$EXTRA$SUFFIX
#and a thumbnail of it will be called:
#e.g. THUMB=$PIC$TIMESTAMP$EXTRA-thumb$SUFFIX
THUMB=$PIC$TIMESTAMP$EXTRA-thumb$SUFFIX

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     \
   $UP/$THUMB

echo "uploading fullsize image to server"

#cp $LOCSCROT/$PIC $UP/$PIC
#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
cp $LOCSCROT/$FULL $UP/$FULL

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...
(http://ks392457.kimsufi.com/stuff/scrots/xrt201310042143-thumb.png) (http://ks392457.kimsufi.com/stuff/scrots/xrt201310042143.png)
looks good.