Re: [dev] Announcing a couple small X11 utilities

From: Max Schillinger <maxschillinger_AT_web.de>
Date: Thu, 17 Aug 2023 23:08:58 +0200

> I don't have an answer to your question, but if all you need is
> cropping, I have a shameless plug for a moderately simple tool
> I wrote a while ago: https://lumidify.org/git/croptool/log.html

Nice tool! It works as described. Thank you.

I needed this patch to be able to compile it:


diff --git a/Makefile b/Makefile
index 9f7b524..0952346 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -20,8 +20,8 @@ DB_LDFLAGS = `pkg-config --libs xext`
 #DB_CFLAGS = -DNODB
 #DB_LDFLAGS =

-CROP_CFLAGS = ${CFLAGS} ${DB_CFLAGS} -Wall -Wextra -D_POSIX_C_SOURCE=200809L `pkg-config --cflags x11` `imlib2-config --cflags`
-CROP_LDFLAGS = ${LDFLAGS} ${DB_LDFLAGS} `pkg-config --libs x11` `imlib2-config --libs` -lm
+CROP_CFLAGS = ${CFLAGS} ${DB_CFLAGS} -Wall -Wextra -D_POSIX_C_SOURCE=200809L `pkg-config --cflags x11` `pkg-config --cflags --libs imlib2`
+CROP_LDFLAGS = ${LDFLAGS} ${DB_LDFLAGS} `pkg-config --libs x11` `pkg-config --cflags --libs imlib2` -lm

 all: ${BIN}


I found this fix here [1]. `imlib2-config` is deprecated if I got it
right.

And it wasn't obvious to me that I have to exit croptool via dwm to get
some output. It would be nice if it supported a common shortcut like
Ctrl-q to quit.

[1]: https://aur.archlinux.org/packages/ipager#comment-865929


For those interested in a solution using feh + sx4 + ImageMagick: I
hacked togehter this little wrapper script. It's far from perfect as it
depends on:

- xdotool being installed
- my shortcut to hide the status bar
- same being visible when the script is started
- a German keyboard layout.

But it works for me :-)

Usage:
crop-image ~/Pictures/cropme.png /tmp/cropped.png

Regards,
Max

---
#!/bin/sh
filename="$1"
filename_cropped="$2"
# disable dwm status bar
xdotool key super+shift+b
feh --borderless "$filename" &
sleep 0.5
# shift+plus = * in a German QWERTZ layout
# '*' zooms to 100% and moves the image to the top-left corner
xdotool search --class feh windowactivate --sync '%1' key 'shift+plus'
geom="$(sx4)"
pkill feh
geom="$(echo ${geom#*,*,} | tr , x)+$(echo ${geom%,*,*} | tr , +)"
magick "$filename" +repage -crop "$geom" "$filename_cropped"
# enable dwm status bar
xdotool key super+shift+b
Received on Thu Aug 17 2023 - 23:08:58 CEST

This archive was generated by hypermail 2.3.0 : Fri Aug 18 2023 - 02:00:12 CEST