Raspberry Pi 3

arduino Raspberry Pi project

Raspberry Pi Setup Screen Shot with Scrot, FEH

by Lewis Loflin

Note this works with any Debian type Linux system. To begin install scrot and feh:

~ $ sudo apt-get install scrot feh

Scrot and Screen Shots


Scrot is a minimalistic command line screen capturing application. Scrot enables taking screenshots from the CLI (terminal) and offers features such as a user-definable time delay. Unless instructed otherwise, it saves the file in the current working directory.

$ scrot -t 20 -d 5

The above command saves a dated .png file, along with a thumbnail (20% of original), for Web posting. It provides a 5 second delay before capturing in this instance. You can also use standard date and time formatting when saving to a file. e.g.,

$ scrot ~/Pictures/%Y-%m-%d-%T-screenshot.png -t 20 -d 5

The above saves the screenshot in a filename with the current year, month, date, hours, minutes, and seconds to a folder in your home directory called "Pictures" after a delay of 5 seconds. Make sure the directory is actually there!

A Better Way

The following bash file will allow screenshots that will open up the image with feh. The image will be stored in directory /home/pi/sshot along with a thumbnail image. Directory sshot will be created if not present.

In this case I've created a bash script that can be called from a pin board or Linux menu.

A "bin" folder is already mapped into the system on the latest Raspbian/Debian distributions in one's home directory.

The advantage is low system resource use and fast operation. Save as sshot.sh in /home/pi/bin. Open a terminal window in the folder:

~ $ sudo chmod +x sshot.sh

Now the file will execute. Call from terminal or add to menu, etc.




#!/bin/bash

# Make sure scrot and feh are installed!
# sudo apt-get install scrot feh

# check if X display is working
[ -z ${DISPLAY} ] && echo "Requires X" &&  exit 1

# check for ~/sshot make if not there.
[ -d "$HOME/sshot" ] || mkdir -p "$HOME/sshot"

# to save to directory ~/sshot
filename=~/sshot/pic_`date "+%m%d%H%M%S"`.png

# -d sleep 3 
# -t, --thumb NUM generate thumbnail too. 
# NUM is percentage of the original 
scrot  -d 3 $filename -t 20                     

# use feh to display screen shot at reduced size
# -g --geometry [width x height] [+ x + y]
# -d --draw-filename Draw the filename 
# at the top-left of the image.
# -S --sort sort_type
# The file list may be sorted 
# according to image parameters.
# Allowed sort types are: name, filename, time, 
# width, height, pixels, size, format.

feh -g 600x400 -d  -S $filename

exit