Monday, April 28, 2025

How to take screenshot - OpenBSD - Scroot

We can take a screenshot in UNIX/BSD/Linux systems with "scrot" program.

First, I will install it on my OpenBSD system. Let's define location where packages are, with PKG_PATH:

# export PKG_PATH=http://ftp.vim.org/OpenBSD/4.8/packages/i386 
Checking program description and location with "pkg_info scrot": 
# pkg_info scrot    
Information for http://ftp.vim.org/OpenBSD/4.8/packages/i386/scrot-0.8p1.tgz

Comment:
commandline screen capture util

Description:
scrot is a commandline screen capture util like "import", but using
imlib2. It has lots of options for autogenerating filenames, and can
do fun stuff like taking screenshots of multiple displays and glueing
them together.

Maintainer: Victor Sahlstedt 

WWW: http://www.linuxbrit.co.uk/scrot/ 
Ok. Now we will instal scrot with pkg_add: 
# pkg_add -v scrot-0.8p1.tgz

scrot-0.8p1:imlib2-1.4.2p1: ok                                                 
scrot-0.8p1:giblib-1.2.4p4: ok                                                 
scrot-0.8p1: ok                                                                
# 

That's fine. Please note that saved shots will be in working directory. In this case "/home/scrot":

#pwd
/home 
# mkdir scrot
# cd scrot
# pwd
/home/scrot

So far, so good. Take note about naming convention : 

# man scrot man: Formatting manual page...

scrot(1)                                                 scrot(1)

NAME
       scrot - Screen capture using imlib2

SYNOPSIS
       scrot [options] [file]

DESCRIPTION
       scrot  is  a  screen capture utility using the imlib2 library to aquire
       and save images.  scrot has a  few  options,  detailed  below.  Specify
       [file]  as  the  filename  to save the screenshot to.  If [file] is not
       specified, a date-stamped file will be dropped in  the  current  direc-
       tory.

Last check, are we in right directory ?

# pwd
/home/scrot
# ls
# 

To get a screenshot of whole screen, we need just "scrot", without additional options. Default filetype is .png. Take note about timestamp.

# scrot
# ls
2013-01-04-152547_1024x768_scrot.png
# 

If we need countdown option:  

# scrot -d 5 -c 

Taking shot in 5.. 4.. 3.. 2.. 1.. 0.
# ls
2013-01-04-152547_1024x768_scrot.png    2013-01-04-152940_1024x768_scrot.png
#    

In case above, "-d" is for countdown, "5" is number of seconds, and "-c" is for showing countdown on screen.

You can define quality of screenshot in range scale up to 100. Default quality is 75. We will use "scrot -q 10", just to test it:

# scrot -q 10 
# ls -lh 

total 548
-rw-r--r--  1 root  wheel  94.2K Jan  4 15:25 2013-01-04-152547_1024x768_scrot.png
-rw-r--r--  1 root  wheel  95.5K Jan  4 15:29 2013-01-04-152940_1024x768_scrot.png
-rw-r--r--  1 root  wheel  81.1K Jan  4 15:32 2013-01-04-153221_1024x768_scrot.png
# 

Pay attention to size of shot on 153221, it's smaller than 152940, of course.

How to change file type for screenshot ? For example, use "$t filename.jpg" :

# scrot $t desktop.jpg
# ls -lh
total 792
-rw-r--r--  1 root  wheel  94.2K Jan  4 15:25 2013-01-04-152547_1024x768_scrot.png
-rw-r--r--  1 root  wheel  95.5K Jan  4 15:29 2013-01-04-152940_1024x768_scrot.png
-rw-r--r--  1 root  wheel  81.1K Jan  4 15:32 2013-01-04-153221_1024x768_scrot.png
-rw-r--r--  1 root  wheel   120K Jan  4 15:38 desktop.jpg

Now we have screenshot in .jpg format.

How to take screenshot of window, or region ?

Use "scrot -s" command, pres ENTER, left mouse clickdefine region, release click, wait for prompt:

# scrot -s $t windows.jpg  
# ls -hl
total 876
-rw-r--r--  1 root  wheel  94.2K Jan  4 15:25 2013-01-04-152547_1024x768_scrot.png
-rw-r--r--  1 root  wheel  95.5K Jan  4 15:29 2013-01-04-152940_1024x768_scrot.png
-rw-r--r--  1 root  wheel  81.1K Jan  4 15:32 2013-01-04-153221_1024x768_scrot.png
-rw-r--r--  1 root  wheel   120K Jan  4 15:38 desktop.jpg
-rw-r--r--  1 root  wheel  41.8K Jan  4 15:42 windows.jpg 

New file is windows.jpg, and that file is smaller, because region for shot is smaller than whole screen.

Scrot program have option to define shot width, height, to execute additional command after taking shot (copy to another dir), etc.

Check man page for your version of scrot.

No comments:

Post a Comment

Tkinter Introduction - Top Widget, Method, Button

First, let's make shure that our tkinter module is working ok with simple  for loop that will spawn 5 instances of blank Tk window .  ...