#wayland #screenshot #sway #screen-capture #wayland-compositor #screencopy #scrot

gazo

Gazo is a library to get a screen capture from Wayland compositors implementing the wlr_screencopy protocol, like Sway

2 releases

0.0.3 Dec 29, 2022
0.0.2 Jun 25, 2022

#933 in GUI

GPL-3.0-or-later

48KB
1.5K SLoC

Wayland Screencopy Utilites

This repository contains a library (gazo) and binary tools (gazo-cli and qrode) written in Rust. Gazo can be used as a library or cli tool to capture the screen output of Wayland compositors implementing the wlr screencopy protocol. Qrode uses gazo to capture a region of the screen and decode QR codes; the QR code is then opened as a link, if that fails it is opened as a text file.

Syndelis created a fork called XQRode that works the same way as QRode, but is for Xorg environments. Big thanks to them for the addition, I hope to incorporate that effort here one day.

If anything is unclear or not working, please open an issue.

Please remember these projects are still in early development and there will be bugs. One current limitation of qrode is that it tends to fail to decode non-standard QR codes. Any problems with decoding QR codes should be reported to the rqrr crate (please don't bother them too much and make sure not to open duplicate issues).

Installation

Manual

Clone the repository using git and cd into it.

git clone https://gitlab.com/redArch/wayland-screencopy-utilities
cd wayland-screencopy-utilities

Qrode and gazo-cli can be built using Cargo.

cargo build --release --target-dir qrode # or gazo-cli

The built binary can be found in "./target/release/".

AUR

Qrode and gazo are available in the AUR as "qrode-git" and "gazo-git", respectively.

yay -S qrode-git
yay -S gazo-git

Usage

Qrode works best with slurp. See below for typical usage.

qrode -g "$(slurp)"

Example usage of qrode in a GIF

Gazo-cli partially emulates grim in terms of its arguments, but it is not a complete drop in replacement (although that may or may not change). See below for example uses.

gazo screenshot.png # capture all outputs and save in screenshot.png

gazo -o "DP-1" screenshot.png # capture the output named "DP-1"

gazo -g "$(slurp)" screenshot.png # capture the region specified by slurp

Some notes about gazo: it only supports PNG images currently (this may or may not change); there is no level flag for PNG compression as the library used does not have an option for setting the compression level; and Wayland output scaling is handled, but a scaling factor cannot be set like grim (scaling factor is 1 for all images for now).

Both qrode and gazo have a help option if you get stuck or want to see other options that may not be listed here.

qrode -h # print the qrode help
gazo -h  # print the gazo help

Acknowledgments

These projects depend heavily on other projects, and without them it would not have been possible for me to create qrode and gazo. A non-exhaustive list of helpful projects I would like to thank:

  • The Smithay project wayland-client and wayland-protocols crates
  • The rqrr crate, used to decode QR codes for qrode
  • The mtpng crate, used to encode image data into the PNG format extremely quickly
  • The clap crate, used to parse arguments from the command line
  • The memmap2 crate, used to map memory backed files for easy manipulation

Contributing

If you'd like to contribute, please open an issue. This repository is still in early development, so there will probably be a lot of major changes that will make collaborating difficult.

License

GPL-3.0

Donations

If you like this project and want to support me, you can buy me a coffee.


lib.rs:

Gazo is a crate to capture screen pixel data on Wayland compositors that implement the wlr_screencopy protocol, like sway.

Dependencies

~4–12MB
~115K SLoC