Skip to content

Playing around with Screenshots and SSH Servers

During the weekend I find out an Enlightenment epplet that allowed me to take an screenshot and upload it to a FTP server. But it wasn’t working quite right. So I made my own scripts.

Of course I use other already existant software, make sure you have this packages installed before continue.

  • ssh
  • scrot

And of course ssh access in your server, preferently passwordless access using public key authentication (ok, if you have all this you probably can make your own script).

It’s pretty simple actually, first you must create a directory tree like this (for the moment just follow the instructions, you can play with it later):

# mkdir ~/screenshot
# mkdir ~/screenshot/images
# mkdir ~/screenshot/thumbnails

The first script would be called (and you must chmod it to 700)

cd ~/screenshot/
scrot -t 20 '%Y-%m-%d-%H-%M-%S.jpg' -e 'mv $f images/; mv $m thumbnails/; ./ $f $m'

It takes the screenshot on jpg format, include a thumbnail of 20% the original size, move this files to images and thumbnails, and run the script.

scp images/$1 $user@$host:$dir/screenshot.jpg
scp thumbnails/$2 $user@$host:$dir/thumbnail.jpg

I use public key authentication so I don’t need to provide a password, make your own tests if you don’t have this.

The script copy the given files ($1 and $2) to the given directory on the given host. Really simple.

I splited the screenshot taker and the uploader script to simplify the implementation of further uploaders. A ftp and cURL uploader would be nice, for the moment this make the job for me (and any other ssh-public-key-authenticated user)

Finally I made a symbolic on /usr/bin/

# cd /user/bin/
# sudo ln -s /home/user/screenshot/

And a launcher on my gnome applet, so I only click the launcher and I have an updated screenshot on my blog, like this one below.

screenshot working!

Post a Comment

Your email is never published nor shared. Required fields are marked *