selk | Keyboard-only rectangle selector for X |
| download: https://git.y1.nz/archives/selk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
main.c
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 #include <X11/Xlib.h>
5 #include <X11/Xutil.h>
6 #include <X11/keysym.h>
7
8 #include "draw.h"
9
10 const char * usage = \
11 "Selk 1.1 🄯 Emma 2026" "\n\n" \
12 "Usage: selk [--help]" "\n\n" \
13 "Keyboard-based rectangle selector." "\n" \
14 "Controls:" "\n" \
15 " [hjkl]: move selection" "\n" \
16 " [shift]: slower" "\n" \
17 " [control]: faster" "\n" \
18 " [space]: confirm" "\n" \
19 " [m]: output monitor" "\n" \
20 " [n]: output window" "\n" \
21 " [escape]: cancel" "\n" \
22 "Position the top-left corner, press space, position" "\n" \
23 "the bottom corner, press space again. Or, at any" "\n" \
24 "time press m or n." "\n" \
25 "\n";
26
27 int
28 main(int argc, const char * argv[])
29 {
30 X11 x11;
31 DrawContext ctx;
32
33 /* print usage if format isn't correct */
34 if (argc != 1) {
35 printf(usage);
36 exit(0);
37 }
38
39 /* pick a rectangle */
40 set_up(&ctx, &x11);
41 run_draw_loop(&ctx, &x11);
42 clean_up(&ctx, &x11);
43 Rect rect = get_rectangle(&ctx, &x11);
44 XCloseDisplay(x11.display);
45
46 printf("%d %d %d %d" "\n", rect.x, rect.y, rect.w, rect.h);
47
48 return 0;
49 }
50
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.