neXromancers / shotgun

Minimal X screenshot utility

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Separate logic into crate?

jD91mZM2 opened this issue · comments

Hey! This looks really cool! Any chance you could separate the logic to a separate crate so people could use it in their own applications?

Thanks for the compliment and suggestion. This doesn't sound like a bad idea at all, I'll look into it when I can.

I'll need more details on what you actually expect from the separate crate. I've glanced at my code, and most of the logic is for processing user input. The rest is a very thin wrapper around Xlib, and copying buffers around.
What interface should I provide? I'm thinking of letting the consumer open the X connection themselves, then calling a single function with optional window ID and geometry, which then returns the screenshot as an image::RgbaImage.

I imagined something high-level like

let mut display = Display::new(":0");
let image = display.capture_window(<id>); // returns struct with: width, height and byte vec

(But it's completely up to you)

Any news on this?

Well as I've said before, I'm not sure what kind of API I should provide. The problem is more complex than the proposition above, but also still trivial enough to make a library crate unnecessary. I think the best I could do would be exposing the same parameters as the command-line interface, and returning a struct from the Image crate, but that's a major refactoring.

Another major blocker is that I don't use shotgun anymore, as I've switched to Wayland, and I'm not interested in doing this either way. I will gladly review a pull request implementing the above though.

@9ary Oh, why did you switched to wayland? Which wayland do you use? Do you have any issues? How was it?

I'm using sway. The main motivation was extremely poor performance and a buggy experience with Intel graphics on my laptop, as well as the lack of a good compositor for X. sway solves all of this.
Wayland in general is a much better protocol than X11, which was not designed for modern hardware and has accumulated a lot of cruft which is difficult to keep working well and modernize.

@9ary Ah, I am interested to hear more, I also use Intel on my side. Let's take this offline, maybe on telegram chat later.

I'll close this as you're right, the crate might be too small if you extract out all argument handling