Skip to content

tinyopsec/capta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

capta



MIT C99 Linux Imlib2 PRs Welcome


capta is a minimal, fast screenshot utility for X11. No daemons, no config files, no GUI overhead.

Features

  • Full-screen capture
  • Focused window capture
  • Interactive region or window selection with a crosshair cursor
  • Capture delay (useful for menus and tooltips)
  • Image quality control from 1 to 100
  • Auto-generated timestamped filenames when no output path is given

Installation

Requires libX11 and Imlib2 development headers.

git clone --depth 1 https://github.com/tinyopsec/capta
cd capta
make
sudo make install

Usage

capta [-s] [-u] [-d sec] [-q 1-100] [file]
Flag Description
-s Select a region or window with the mouse
-u Capture the currently focused window
-d sec Delay sec seconds before capturing
-q num Image quality 1-100 (default 75)
file Output path; auto-named if omitted

Examples

capta                        # full screen, auto-named
capta screenshot.png         # full screen to a file
capta -s                     # select a region
capta -s -q 95 region.jpg    # select, high quality JPEG
capta -u window.png          # focused window
capta -d 3                   # 3-second delay, then full screen
capta -d 2 -s capture.png    # delay then select

How It Works

  1. parseargs() parses the CLI flags.
  2. initx() connects to the X display and sets up the Imlib2 context.
  3. If a delay was requested, capta sleeps for it.
  4. capta grabs the image using one of three strategies:
    • grabfull(): full-screen capture via imlib_create_image_from_drawable on the root window
    • grabfocused(): finds the focused window with XGetInputFocus, then hands off to grabwin()
    • grabsel(): grabs the pointer and draws an XOR rubber-band selection, then calls grabwin() on a window or crops to the selected rectangle
  5. saveimg() writes the result out with imlib_save_image_with_error_return.

A drag smaller than 2x2 px in selection mode captures the window under the cursor rather than a region.

Source Layout

File Contents
capta.c main logic: argument parsing, grab strategies, entry point
imlib.c X11 init and Imlib2 save wrapper
imlib.h shared display/screen globals and function declarations
Makefile build, install, clean targets
LICENSE MIT

Contributing

Patches and bug reports are welcome. Keep C99, avoid extra dependencies, avoid dynamic allocation where unnecessary.

make clean && make

About

Screenshot utility for X11. No bloat.

Topics

Resources

License

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors