Description: added --autoselect rectangle option Author: Stoney Sauce <stoneysauce@gmail.com> Last-Update: 2017-01-28 Index: scrot-0.8/src/options.c =================================================================== --- scrot-0.8.orig/src/options.c +++ scrot-0.8/src/options.c @@ -44,7 +44,7 @@ static void scrot_parse_option_array(int argc, char **argv) { - static char stropts[] = "bcd:e:hmq:st:uv+:z"; + static char stropts[] = "a:bcd:e:hmq:st:uv+:z"; static struct option lopts[] = { /* actions */ {"help", 0, 0, 'h'}, /* okay */ @@ -55,13 +55,14 @@ {"focussed", 0, 0, 'u'}, /* macquarie dictionary has both spellings */ {"border", 0, 0, 'b'}, {"multidisp", 0, 0, 'm'}, - {"silent", 0, 0, 'z'}, + {"silent", 0, 0, 'z'}, /* toggles */ {"thumb", 1, 0, 't'}, {"delay", 1, 0, 'd'}, {"quality", 1, 0, 'q'}, {"exec", 1, 0, 'e'}, {"debug-level", 1, 0, '+'}, + {"autoselect", required_argument, 0, 'a'}, {0, 0, 0, 0} }; int optch = 0, cmdx = 0; @@ -113,6 +114,9 @@ case 'z': opt.silent = 1; break; + case 'a': + options_parse_autoselect(optarg); + break; default: break; } @@ -173,6 +177,27 @@ } void +options_parse_autoselect(char *optarg) +{ + char *tok; + const char tokdelim[2] = ","; + int dimensions[4]; + int i=0; + + if (strchr(optarg, ',')) /* geometry dimensions must be in format x,y,w,h */ + { + dimensions[i++] = atoi(strtok(optarg, tokdelim)); + while (tok = strtok(NULL, tokdelim) ) + dimensions[i++] = atoi(tok); + opt.autoselect=1; + opt.autoselect_x=dimensions[0]; + opt.autoselect_y=dimensions[1]; + opt.autoselect_w=dimensions[2]; + opt.autoselect_h=dimensions[3]; + } +} + +void options_parse_thumbnail(char *optarg) { char *tok; @@ -234,6 +259,7 @@ " current directory.\n" " See man " PACKAGE " for more details\n" " -h, --help display this help and exit\n" " -v, --version output version information and exit\n" + " -a, --autoselect non-interactively choose a rectangle of x,y,w,h\n" " -b, --border When selecting a window, grab wm border too\n" " -c, --count show a countdown before taking the shot\n" " -d, --delay NUM wait NUM seconds before taking a shot\n" Index: scrot-0.8/src/options.h =================================================================== --- scrot-0.8.orig/src/options.h +++ scrot-0.8/src/options.h @@ -43,11 +43,17 @@ char *output_file; char *thumb_file; char *exec; + int autoselect; + int autoselect_x; + int autoselect_y; + int autoselect_h; + int autoselect_w; }; void init_parse_options(int argc, char **argv); char *name_thumbnail(char *name); void options_parse_thumbnail(char *optarg); +void options_parse_autoselect(char *optarg); extern scrotoptions opt; #endif Index: scrot-0.8/src/main.c =================================================================== --- scrot-0.8.orig/src/main.c +++ scrot-0.8/src/main.c @@ -52,7 +52,10 @@ image = scrot_grab_focused(); else if (opt.select) image = scrot_sel_and_grab_image(); - else { + else if (opt.autoselect) + image = gib_imlib_create_image_from_drawable(root, 0, opt.autoselect_x, opt.autoselect_y, opt.autoselect_w, opt.autoselect_h, 1); + else + { scrot_do_delay(); if (opt.multidisp) { image = scrot_grab_shot_multi();
Attachment:
scrot_0.8-18.debian.tar.xz
Description: application/xz