Howdy,
I've created a patch for sxot that adds a -m (--monitor) param that allows to select which monitor to capture in a multihead setup. Let me know what you think.
Regards, Yan On 7/4/23 15:51, NRK wrote:
Hi all, I'd like to share some small X11 utilities that I've developed and have been using in my daily setup. The utilities are all fairly small in size and requires only typical X libraries. sxcs ==== This is a simple color picker and magnifier. My issue with all other existing minimal color pickers were that due to no magnification, picking out specific pixels was fairly difficult. The usage is simple, you launch the program and pick a color. The result will be output to stdout in tab separated RGB, HSL and HEX format. Repo: https://codeberg.org/NRK/sxcs SLoC: ~628 Dependencies: Xlib, libXcursor sxot ==== This one is a *very minimal* screenshot tool. I wrote this when I realized that other cli screenshot tools (scrot, maim) do way too much. sxot on the other hand is meant to follow the unix philosophy - it simply takes a screenshot and outputs a binary ppm image to stdout. Any other functionalities are supposed to be handled by more specialized tools. E.g sx4 (see below) for selection, optipng to convert to png, xclip for copying to clipboard etc. Repo: https://codeberg.org/NRK/sxot SLoC: ~251 Dependencies: Xlib, libXfixes sx4 === This one is a selection tool. It outputs the selection rectangle to stdout which can then be used for other purposes, such as screenshoting or screen-recording a specific area. Repo: https://codeberg.org/NRK/sx4 SLoC: ~500 Dependencies: Xlib, libXext --- And that's all. Feel free to report any bugs, send bug-fixes, request additional features (within the project's scope) etc. - NRK
diff --git a/sxot.c b/sxot.c index de87126..712ba66 100644 --- a/sxot.c +++ b/sxot.c @@ -31,6 +31,7 @@ #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/extensions/Xfixes.h> +#include <X11/extensions/Xrandr.h> typedef uint8_t u8; typedef uint32_t u32; @@ -207,6 +208,7 @@ main(int argc, char *argv[]) "usage: sxot [options]\n" "Options:\n" " -g, --geom <x,y,w,h> Capture the specified rectangle\n" + " -m, --monitor n Capture the specified monitor\n" " -c, --curosr Capture the cursor also\n" ); Str version = S( @@ -237,6 +239,20 @@ main(int argc, char *argv[]) if (!parse_geom(opt.v, str_from_cstr(argv[++i]))) { fatal(S("invalid geometry\n")); } + + } else if (str_eq(arg, S("--monitor")) || str_eq(arg, S("-m"))) { + int m[1]; + str_to_int(str_from_cstr(argv[++i]), m); + + XRRScreenResources *screen; + screen = XRRGetScreenResources (x11.dpy, DefaultRootWindow(x11.dpy)); + XRRCrtcInfo *crtc_info; + crtc_info = XRRGetCrtcInfo (x11.dpy, screen, screen->crtcs[m[0]]); + + opt.x = crtc_info->x; + opt.y = crtc_info->y; + opt.h = crtc_info->height; + opt.w = crtc_info->width; } else if (str_eq(arg, S("--cursor")) || str_eq(arg, S("-c"))) { opt.capture_cursor = true; } else if (str_eq(arg, S("--help")) || str_eq(arg, S("-h"))) {
OpenPGP_signature.asc
Description: OpenPGP digital signature