mirror of
https://github.com/swaywm/sway.git
synced 2024-11-29 11:21:28 +00:00
Enable geometry on swaygrab options
This commit is contained in:
parent
d75ee3f9ce
commit
6de77fb558
|
@ -168,6 +168,7 @@ int main(int argc, char **argv) {
|
||||||
char *output = NULL;
|
char *output = NULL;
|
||||||
int framerate = 30;
|
int framerate = 30;
|
||||||
bool grab_focused = false;
|
bool grab_focused = false;
|
||||||
|
char *geometry = NULL;
|
||||||
|
|
||||||
init_log(L_INFO);
|
init_log(L_INFO);
|
||||||
|
|
||||||
|
@ -180,29 +181,34 @@ int main(int argc, char **argv) {
|
||||||
{"raw", no_argument, NULL, 'r'},
|
{"raw", no_argument, NULL, 'r'},
|
||||||
{"rate", required_argument, NULL, 'R'},
|
{"rate", required_argument, NULL, 'R'},
|
||||||
{"focused", no_argument, NULL, 'f'},
|
{"focused", no_argument, NULL, 'f'},
|
||||||
|
{"geometry", required_argument, NULL, 'g'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *usage =
|
const char *usage =
|
||||||
"Usage: swaygrab [options] [file]\n"
|
"Usage: swaygrab [options] [file]\n"
|
||||||
"\n"
|
"\n"
|
||||||
" -h, --help Show help message and quit.\n"
|
" -h, --help Show help message and quit.\n"
|
||||||
" -c, --capture Capture video.\n"
|
" -c, --capture Capture video.\n"
|
||||||
" -o, --output <output> Output source.\n"
|
" -o, --output <output> Output source.\n"
|
||||||
" -v, --version Show the version number and quit.\n"
|
" -v, --version Show the version number and quit.\n"
|
||||||
" -s, --socket <socket> Use the specified socket.\n"
|
" -s, --socket <socket> Use the specified socket.\n"
|
||||||
" -R, --rate <rate> Specify framerate (default: 30)\n"
|
" -R, --rate <rate> Specify framerate (default: 30)\n"
|
||||||
" -r, --raw Write raw rgba data to stdout.\n"
|
" -r, --raw Write raw rgba data to stdout.\n"
|
||||||
" -f, --focused Grab the focused container.\n";
|
" -f, --focused Grab the focused container.\n"
|
||||||
|
" -g, --geometry <wxh+x+y> Sets the region to capture (default: fullscreen).\n";
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
while (1) {
|
while (1) {
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
c = getopt_long(argc, argv, "hco:vs:R:rf", long_options, &option_index);
|
c = getopt_long(argc, argv, "hco:vs:R:rfg:", long_options, &option_index);
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case 'g':
|
||||||
|
geometry = strdup(optarg);
|
||||||
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
grab_focused = true;
|
grab_focused = true;
|
||||||
break;
|
break;
|
||||||
|
@ -261,6 +267,13 @@ int main(int argc, char **argv) {
|
||||||
json_object_object_get_ex(con, "name", &name);
|
json_object_object_get_ex(con, "name", &name);
|
||||||
geo = get_container_geometry(con);
|
geo = get_container_geometry(con);
|
||||||
free(con);
|
free(con);
|
||||||
|
} else if (geometry) {
|
||||||
|
geo = malloc(sizeof(struct wlc_geometry));
|
||||||
|
int read = sscanf(geometry, "%ux%u%d%d",
|
||||||
|
&geo->size.w, &geo->size.h, &geo->origin.x, &geo->origin.y);
|
||||||
|
if (read != 4) {
|
||||||
|
sway_abort("Unable to parse geometry");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!output) {
|
if (!output) {
|
||||||
output = get_focused_output();
|
output = get_focused_output();
|
||||||
|
|
Loading…
Reference in a new issue