From 32df818c67f148f7b849147a3ce8880d0f871592 Mon Sep 17 00:00:00 2001 From: r1w1s1 Date: Sun, 14 Dec 2025 22:42:13 -0300 Subject: Makefile: respect CPPFLAGS and CFLAGS when building --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 33ef70c..9c9151b 100644 --- a/Makefile +++ b/Makefile @@ -8,12 +8,12 @@ MANPREFIX = ${PREFIX}/share/man # libs # remove the Xinerama parts if you don't want Xinerama support LIBS = -lX11 -lXinerama -CPPFLAGS = -DXINERAMA # flags -# CFLAGS = -std=c99 -Wall -Wextra -O0 -g ${CPPFLAGS} -fdiagnostics-color=always # debug -CFLAGS = -std=c99 -Wall -Wextra -Os ${CPPFLAGS} -fdiagnostics-color=always -I/usr/X11R6/include -LDFLAGS = ${LIBS} -L/usr/X11R6/lib +CPPFLAGS = -DXINERAMA +# CFLAGS = -std=c99 -Wall -Wextra -O0 -g -fdiagnostics-color=always # debug +CFLAGS = -std=c99 -Wall -Wextra -Os -fdiagnostics-color=always +LDFLAGS = ${LIBS} # files SRC = xnap.c @@ -22,7 +22,7 @@ all: xnap # rules xnap: - ${CC} ${SRC} -o xnap ${LDFLAGS} + ${CC} ${CPPFLAGS} ${CFLAGS} ${SRC} -o xnap ${LDFLAGS} clean: rm -rf xnap @@ -41,6 +41,6 @@ uninstall: clangd: rm -f compile_flags.txt - for f in ${CFLAGS}; do echo $$f >> compile_flags.txt; done + for f in ${CPPFLAGS} ${CFLAGS}; do echo $$f >> compile_flags.txt; done .PHONY: all clean install uninstall clangd -- cgit v1.2.3 From b8e0d8add81f9d71cfb62c0ff6f2e631a90b6a45 Mon Sep 17 00:00:00 2001 From: r1w1s1 Date: Sun, 14 Dec 2025 22:42:22 -0300 Subject: manpage: clarify stdout PPM output and usage --- xnap.1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xnap.1 b/xnap.1 index d255c85..90b7088 100644 --- a/xnap.1 +++ b/xnap.1 @@ -9,7 +9,7 @@ xnap \- minimal X11 screenshot utility .IR n ] .SH DESCRIPTION .B xnap -captures screen contents from an X11 display and writes to a PPM6 image +captures screen contents from an X11 display and writes a PPM6 image to standard output. .PP By default, @@ -26,18 +26,18 @@ Capture the full root window; the whole screen. Capture the window currently under the pointer. .TP .BI \-s " N" -Capture screen N -.I n -as reported by the Xinerama extension. +Capture screen N as reported by the Xinerama extension. .SH OUTPUT .B xnap -writes a PPM (P6) image to stdout. +writes a binary PPM (P6) image to standard output (stdout). .SH USAGE Redirect output to a file or pipe it to another program: .PP .nf xnap > image.ppm -xnap \-f | converto... whatever.png +xnap -f > fullscreen.ppm +xnap -s 0 > screen0.ppm +xnap | convert ppm:- image.png .fi .SH ENVIRONMENT .TP -- cgit v1.2.3 From 9d5460c1c69ffd14350a1016d98a0b1c20e1dd7d Mon Sep 17 00:00:00 2001 From: r1w1s1 Date: Sun, 14 Dec 2025 22:42:29 -0300 Subject: README: clarify stdout output and examples --- README.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d66734c..2671fdd 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,52 @@ # xnap -xnap is a minimalistic screenshot utility for X. -just `make install` +xnap is a minimal screenshot utility for X11. -you **need** `Xlib` and can use `Xinerama` optionally. -xnap is minimal and just outputs the image contents (PPM format) to the stdout. -please use a tool to collect that info and store / convert it to whatever you like. +It captures screen contents and writes a raw PPM (P6) image to standard +output. xnap does not save files by itself and does not perform image +conversion. -enjoy! +## Building and installing + +make +sudo make install + +## Dependencies + +- Xlib (required) +- Xinerama (optional, for multi-monitor support) + +## Usage + +xnap always writes image data to stdout. Redirect the output to a file or +pipe it to another program for conversion or storage. + +Examples: + +# Select a region and save as PPM +xnap > image.ppm + +# Capture the full screen +xnap -f > fullscreen.ppm + +# Capture screen 0 (Xinerama) +xnap -s 0 > screen0.ppm + +# Convert to PNG using ImageMagick +xnap | convert ppm:- image.png + +## Example key binding + +Using sxwm: + +bind : mod + shift + s : "bash -c 'xnap | pnmtopng | tee ~/Pictures/screenshots/$(date +%Y-%m-%d_%H-%M).png | xclip -selection clipboard -t image/png'" + +## Philosophy + +xnap follows the Unix philosophy: +- do one thing +- do it simply +- leave storage and conversion to other tools + +Enjoy! -> example usage -> sxwm: `bind : mod + shift + s : "bash -c 'xnap | pnmtopng | tee ~/Pictures/screenshots/$(date +%Y-%m-%d_%H-%M).png | xclip -selection clipboard -t image/png'"` -- cgit v1.2.3