Jim's Window Manager desktop.


Scrot Lite Weight Screen Shot Software for Linux

by Lewis Loflin


The above was taken with the scrot-feh program below.

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

 ~ $ sudo apt-get install scrot feh

Scrot Simple Screenshots for Linux

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.

Put in your home bin folder or copy to /usr/local/bin.


#!/bin/bash
# screenshot opened with feh or viewnior picture viewer.

# check if X display is working if not exit.
[ -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 "+H%M%S"`.png
filename=~/sshot/pic_`date "+%m%d%H%M%S"`.png

# -d is delay in seconds. 
# -t is thumbnail in percent
scrot -d 3 -t 50  $filename                      

# use feh to display screen shot at reduced size
# -d draws the file name
# -g sets size to no larger than 640x480 or 800x600
feh -g 800x600  $filename

# comment out feh above and use alternate viewer
#viewnior $filename 

exit

Basic Electronics Learning and Projects

Web site Copyright Lewis Loflin, All rights reserved.
If using this material on another site, please provide a link back to my site.