๐Ÿ“ฆ longregen / fastshot

โ˜… 0 stars โ‘‚ 0 forks ๐Ÿ‘ 0 watching
๐Ÿ“ฅ Clone https://github.com/longregen/fastshot.git
HTTPS git clone https://github.com/longregen/fastshot.git
SSH git clone git@github.com:longregen/fastshot.git
CLI gh repo clone longregen/fastshot
Claude Claude feat: add loop mode with duplicate detection and NixOS module 7a1bdbe 1 months ago ๐Ÿ“ History
๐Ÿ“‚ main View all commits โ†’
๐Ÿ“ src
๐Ÿ“ tests
๐Ÿ“„ .gitignore
๐Ÿ“„ default.nix
๐Ÿ“„ flake.lock
๐Ÿ“„ flake.nix
๐Ÿ“„ module.nix
๐Ÿ“„ README.md
๐Ÿ“„ README.md

fastshot

A screenshot utility for KDE Plasma 6 on Wayland. Captures screenshots via KWin's D-Bus interface and saves them as PNG files.

Features

  • Single-shot mode: take one screenshot and exit
  • Loop mode: continuous screenshots at configurable intervals
  • Image comparison: skips saving duplicate/similar screenshots using SIMD-optimized comparison
  • Async PNG writing: screenshots are saved in background threads to avoid blocking capture

Requirements

  • KDE Plasma 6 with KWin Wayland compositor
  • systemd (for D-Bus session bus access)
  • libpng

Usage

Single shot

fastshot [output.png]

Takes a screenshot of the active screen and saves it. If no filename is provided, uses timestamp format YYYY.MM.DD-HH.MM.SS.png.

Loop mode

fastshot --loop [options]

Runs continuously, taking screenshots at regular intervals. Only saves when the screen content has changed beyond the similarity threshold.

Options:

OptionDescriptionDefault
--loopEnable continuous screenshot mode-
-d, --directory DIROutput directory~/desktop-record
-i, --interval SECSSeconds between captures45
-t, --threshold FLOATSimilarity threshold (0-1). Only saves if similarity is below this value0.99
-v, --verboseEnable verbose loggingoff
-h, --helpShow help-
Example:

fastshot --loop --directory ~/screenshots --interval 10 --threshold 0.95

This captures every 10 seconds and saves only when the screen differs by more than 5% from the last saved image.

NixOS Module

A NixOS module is provided for running fastshot as a user service.

Configuration

{
  imports = [ ./path/to/fastshot/module.nix ];

  services.fastshot = {
    enable = true;
    user = "alice";            # required: user to run the service for
    directory = "screenshots";  # relative to $HOME
    interval = 30;
    threshold = 0.99;
    verbose = false;
  };
}

The service runs as a systemd user unit, starting after graphical-session.target. The user option restricts the service to only run for the specified user.

Building

With Nix

nix build

Or enter a development shell:

nix develop

Manual

cd src
gcc -O3 -mavx2 fastshot.c image-compare.c \
  $(pkg-config --cflags --libs libsystemd libpng) \
  -o fastshot

Requires: gcc, pkg-config, libsystemd-dev, libpng-dev

How it works

  • Connects to the session D-Bus
  • Calls org.kde.KWin.ScreenShot2.CaptureActiveScreen to capture the screen
  • Reads BGRA pixel data from the returned pipe
  • In loop mode, compares against the last saved screenshot using MSE-based similarity
  • Converts BGRA to RGBA and writes PNG (async in loop mode)
The image comparison uses AVX2 SIMD instructions when available for fast pixel differencing.

Files

  • src/fastshot.c - main program
  • src/image-compare.c - SIMD-optimized image comparison
  • module.nix - NixOS service module
  • default.nix - Nix package definition
  • tests/vm.nix - NixOS VM integration test

License

MIT