2 #define I3__FILE__ "commands.c"
19 #define y(x, ...) (cmd_output->json_gen != NULL ? yajl_gen_##x(cmd_output->json_gen, ##__VA_ARGS__) : 0)
20 #define ystr(str) (cmd_output->json_gen != NULL ? yajl_gen_string(cmd_output->json_gen, (unsigned char *)str, strlen(str)) : 0)
21 #define ysuccess(success) \
23 if (cmd_output->json_gen != NULL) { \
30 #define yerror(format, ...) \
32 if (cmd_output->json_gen != NULL) { \
34 sasprintf(&message, format, ##__VA_ARGS__); \
50 #define HANDLE_EMPTY_MATCH \
52 if (match_is_empty(current_match)) { \
53 owindow *ow = smalloc(sizeof(owindow)); \
55 TAILQ_INIT(&owindows); \
56 TAILQ_INSERT_TAIL(&owindows, ow, owindows); \
65 return (a - b) > ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
74 assert(output != NULL);
90 if (strcmp(ws->
name, name) != 0)
93 DLOG(
"This workspace is already focused.\n");
113 if (current == workspace) {
116 DLOG(
"Substituting workspace with back_and_forth, as it is focused.\n");
127 static pid_t migration_pid = -1;
134 static void nagbar_exited(EV_P_ ev_child *watcher,
int revents) {
135 ev_child_stop(EV_A_ watcher);
136 if (!WIFEXITED(watcher->rstatus)) {
137 fprintf(stderr,
"ERROR: i3-nagbar did not exit normally.\n");
141 int exitcode = WEXITSTATUS(watcher->rstatus);
142 printf(
"i3-nagbar process exited with status %d\n", exitcode);
144 fprintf(stderr,
"ERROR: i3-nagbar could not be found. Is it correctly installed on your system?\n");
153 #if EV_VERSION_MAJOR >= 4
159 static void nagbar_cleanup(EV_P_ ev_cleanup *watcher,
int revent) {
160 if (migration_pid != -1) {
161 LOG(
"Sending SIGKILL (9) to i3-nagbar with PID %d\n", migration_pid);
162 kill(migration_pid, SIGKILL);
167 void cmd_MIGRATION_start_nagbar(
void) {
168 if (migration_pid != -1) {
169 fprintf(stderr,
"i3-nagbar already running.\n");
172 fprintf(stderr,
"Starting i3-nagbar, command parsing differs from expected output.\n");
173 ELOG(
"Please report this on IRC or in the bugtracker. Make sure to include the full debug level logfile:\n");
174 ELOG(
"i3-dump-log | gzip -9c > /tmp/i3.log.gz\n");
175 ELOG(
"FYI: Your i3 version is " I3_VERSION
"\n");
176 migration_pid = fork();
177 if (migration_pid == -1) {
178 warn(
"Could not fork()");
183 if (migration_pid == 0) {
191 "You found a parsing error. Please, please, please, report it!",
202 ev_child *child =
smalloc(
sizeof(ev_child));
209 #if EV_VERSION_MAJOR >= 4
212 ev_cleanup *cleanup =
smalloc(
sizeof(ev_cleanup));
236 static owindows_head owindows;
272 DLOG(
"match specification finished, matching...\n");
275 struct owindows_head old = owindows;
284 DLOG(
"checking if con %p / %s matches\n", current->
con, current->
con->
name);
287 DLOG(
"matches container!\n");
290 DLOG(
"doesnt match\n");
295 DLOG(
"match by mark\n");
299 DLOG(
"matches window!\n");
302 DLOG(
"doesnt match\n");
319 DLOG(
"ctype=*%s*, cvalue=*%s*\n", ctype, cvalue);
321 if (strcmp(ctype,
"class") == 0) {
326 if (strcmp(ctype,
"instance") == 0) {
331 if (strcmp(ctype,
"window_role") == 0) {
336 if (strcmp(ctype,
"con_id") == 0) {
338 long parsed = strtol(cvalue, &end, 0);
339 if (parsed == LONG_MIN ||
340 parsed == LONG_MAX ||
342 (end && *end !=
'\0')) {
343 ELOG(
"Could not parse con id \"%s\"\n", cvalue);
351 if (strcmp(ctype,
"id") == 0) {
353 long parsed = strtol(cvalue, &end, 0);
354 if (parsed == LONG_MIN ||
355 parsed == LONG_MAX ||
357 (end && *end !=
'\0')) {
358 ELOG(
"Could not parse window id \"%s\"\n", cvalue);
366 if (strcmp(ctype,
"con_mark") == 0) {
371 if (strcmp(ctype,
"title") == 0) {
376 if (strcmp(ctype,
"urgent") == 0) {
377 if (strcasecmp(cvalue,
"latest") == 0 ||
378 strcasecmp(cvalue,
"newest") == 0 ||
379 strcasecmp(cvalue,
"recent") == 0 ||
380 strcasecmp(cvalue,
"last") == 0) {
382 }
else if (strcasecmp(cvalue,
"oldest") == 0 ||
383 strcasecmp(cvalue,
"first") == 0) {
389 ELOG(
"Unknown criterion: %s\n", ctype);
400 DLOG(
"which=%s\n", which);
416 if (strcmp(which,
"next") == 0)
418 else if (strcmp(which,
"prev") == 0)
420 else if (strcmp(which,
"next_on_output") == 0)
422 else if (strcmp(which,
"prev_on_output") == 0)
424 else if (strcmp(which,
"current") == 0)
427 ELOG(
"BUG: called with which=%s\n", which);
437 cmd_output->needs_tree_render =
true;
453 yerror(
"No workspace was previously active.");
464 cmd_output->needs_tree_render =
true;
474 if (strncasecmp(name,
"__", strlen(
"__")) == 0) {
475 LOG(
"You cannot move containers to i3-internal workspaces (\"%s\").\n", name);
486 ELOG(
"No windows match your criteria, cannot move.\n");
495 LOG(
"should move window to workspace %s\n", name);
508 cmd_output->needs_tree_render =
true;
530 LOG(
"should move window to workspace %s\n", which);
532 Con *output, *workspace = NULL;
536 if (parsed_num == -1) {
537 LOG(
"Could not parse initial part of \"%s\" as a number.\n", which);
538 yerror(
"Could not parse number \"%s\"", which);
544 child->
num == parsed_num);
559 cmd_output->needs_tree_render =
true;
565 LOG(
"floating resize\n");
572 if (strcmp(direction,
"up") == 0 || strcmp(direction,
"down") == 0 ||
573 strcmp(direction,
"height") == 0) {
577 px = (px < focused_con->height_increment) ? focused_con->
height_increment : px;
578 }
else if (strcmp(direction,
"left") == 0 || strcmp(direction,
"right") == 0) {
582 px = (px < focused_con->width_increment) ? focused_con->
width_increment : px;
585 if (strcmp(direction,
"up") == 0) {
587 }
else if (strcmp(direction,
"down") == 0 || strcmp(direction,
"height") == 0) {
589 }
else if (strcmp(direction,
"left") == 0) {
599 if (memcmp(&old_rect, &(floating_con->
rect),
sizeof(
Rect)) == 0)
602 if (strcmp(direction,
"up") == 0) {
604 }
else if (strcmp(direction,
"left") == 0) {
614 LOG(
"tiling resize\n");
616 Con *first = current;
618 if (!strcmp(direction,
"left"))
619 search_direction =
D_LEFT;
620 else if (!strcmp(direction,
"right"))
622 else if (!strcmp(direction,
"up"))
623 search_direction =
D_UP;
625 search_direction =
D_DOWN;
629 LOG(
"No second container in this direction found.\n");
636 LOG(
"ins. %d children\n", children);
637 double percentage = 1.0 / children;
638 LOG(
"default percentage = %f\n", percentage);
641 LOG(
"second->percent = %f\n", second->
percent);
642 LOG(
"first->percent before = %f\n", first->
percent);
647 double new_first_percent = first->
percent + ((double)ppt / 100.0);
648 double new_second_percent = second->
percent - ((double)ppt / 100.0);
649 LOG(
"new_first_percent = %f\n", new_first_percent);
650 LOG(
"new_second_percent = %f\n", new_second_percent);
655 first->
percent += ((double)ppt / 100.0);
656 second->
percent -= ((double)ppt / 100.0);
657 LOG(
"first->percent after = %f\n", first->
percent);
658 LOG(
"second->percent after = %f\n", second->
percent);
660 LOG(
"Not resizing, already at minimum size\n");
667 LOG(
"width/height resize\n");
671 current = current->
parent;
675 (strcmp(direction,
"width") == 0 ?
HORIZ :
VERT);
677 while (current->
type != CT_WORKSPACE &&
678 current->
type != CT_FLOATING_CON &&
680 current = current->
parent;
684 LOG(
"ins. %d children\n", children);
685 double percentage = 1.0 / children;
686 LOG(
"default percentage = %f\n", percentage);
690 if ((orientation ==
HORIZ &&
691 strcmp(direction,
"height") == 0) ||
692 (orientation ==
VERT &&
693 strcmp(direction,
"width") == 0)) {
694 LOG(
"You cannot resize in that direction. Your focus is in a %s split container currently.\n",
695 (orientation ==
HORIZ ?
"horizontal" :
"vertical"));
701 LOG(
"This is the only container, cannot resize.\n");
709 LOG(
"child->percent = %f (child %p)\n", child->
percent, child);
714 double new_current_percent = current->
percent + ((double)ppt / 100.0);
715 double subtract_percent = ((double)ppt / 100.0) / (children - 1);
716 LOG(
"new_current_percent = %f\n", new_current_percent);
717 LOG(
"subtract_percent = %f\n", subtract_percent);
721 if (child == current)
724 LOG(
"Not resizing, already at minimum size (child %p would end up with a size of %.f\n", child, child->
percent - subtract_percent);
730 LOG(
"Not resizing, already at minimum size\n");
735 current->
percent += ((double)ppt / 100.0);
736 LOG(
"current->percent after = %f\n", current->
percent);
739 if (child == current)
741 child->
percent -= subtract_percent;
742 LOG(
"child->percent after (%p) = %f\n", child, child->
percent);
754 DLOG(
"resizing in way %s, direction %s, px %s or ppt %s\n", way, direction, resize_px, resize_ppt);
756 int px = atoi(resize_px);
757 int ppt = atoi(resize_ppt);
758 if (strcmp(way,
"shrink") == 0) {
769 DLOG(
"This is a dock window. Not resizing (con = %p)\n)", current->
con);
777 if (strcmp(direction,
"width") == 0 ||
778 strcmp(direction,
"height") == 0) {
788 cmd_output->needs_tree_render =
true;
798 DLOG(
"border style should be changed to %s with border width %s\n", border_style_str, border_width);
807 int tmp_border_width = -1;
808 tmp_border_width = strtol(border_width, &end, 10);
809 if (end == border_width) {
811 tmp_border_width = -1;
813 if (strcmp(border_style_str,
"toggle") == 0) {
817 tmp_border_width = 2;
818 else if (border_style ==
BS_NONE)
819 tmp_border_width = 0;
821 tmp_border_width = 1;
823 if (strcmp(border_style_str,
"normal") == 0)
825 else if (strcmp(border_style_str,
"pixel") == 0)
827 else if (strcmp(border_style_str,
"1pixel") == 0) {
829 tmp_border_width = 1;
830 }
else if (strcmp(border_style_str,
"none") == 0)
833 ELOG(
"BUG: called with border_style=%s\n", border_style_str);
841 cmd_output->needs_tree_render =
true;
851 LOG(
"-------------------------------------------------\n");
852 LOG(
" NOP: %s\n", comment);
853 LOG(
"-------------------------------------------------\n");
861 LOG(
"Appending layout \"%s\"\n", path);
867 LOG(
"JSON content = %d\n", content);
869 ELOG(
"Could not determine the contents of \"%s\", not loading.\n", path);
870 yerror(
"Could not determine the contents of \"%s\".", path);
886 DLOG(
"Appending to parent=%p instead of focused=%p\n", parent,
focused);
887 char *errormsg = NULL;
889 if (errormsg != NULL) {
914 cmd_output->needs_tree_render =
true;
924 DLOG(
"which=%s\n", which);
927 LOG(
"Cannot switch workspace while in global fullscreen\n");
932 if (strcmp(which,
"next") == 0)
934 else if (strcmp(which,
"prev") == 0)
936 else if (strcmp(which,
"next_on_output") == 0)
938 else if (strcmp(which,
"prev_on_output") == 0)
941 ELOG(
"BUG: called with which=%s\n", which);
948 cmd_output->needs_tree_render =
true;
958 Con *output, *workspace = NULL;
961 LOG(
"Cannot switch workspace while in global fullscreen\n");
968 if (parsed_num == -1) {
969 LOG(
"Could not parse initial part of \"%s\" as a number.\n", which);
970 yerror(
"Could not parse number \"%s\"", which);
976 child->
num == parsed_num);
979 LOG(
"There is no workspace with number %ld, creating a new one.\n", parsed_num);
982 cmd_output->needs_tree_render =
true;
989 cmd_output->needs_tree_render =
true;
1000 LOG(
"Cannot switch workspace while in global fullscreen\n");
1007 cmd_output->needs_tree_render =
true;
1017 if (strncasecmp(name,
"__", strlen(
"__")) == 0) {
1018 LOG(
"You cannot switch to the i3-internal workspaces (\"%s\").\n", name);
1024 LOG(
"Cannot switch workspace while in global fullscreen\n");
1029 DLOG(
"should switch to workspace %s\n", name);
1034 cmd_output->needs_tree_render =
true;
1044 DLOG(
"Clearing all windows which have that mark first\n");
1048 if (con->
mark && strcmp(con->
mark, mark) == 0)
1052 DLOG(
"marking window with str %s\n", mark);
1062 cmd_output->needs_tree_render =
true;
1077 DLOG(
"removed all window marks");
1081 if (con->
mark && strcmp(con->
mark, mark) == 0)
1084 DLOG(
"removed window mark %s\n", mark);
1087 cmd_output->needs_tree_render =
true;
1097 DLOG(
"mode=%s\n", mode);
1111 DLOG(
"should move window to output %s\n", name);
1115 Output *current_output = NULL;
1119 assert(current_output != NULL);
1123 LOG(
"No such output found.\n");
1141 cmd_output->needs_tree_render =
true;
1153 DLOG(
"floating_mode=%s\n", floating_mode);
1159 if (strcmp(floating_mode,
"toggle") == 0) {
1160 DLOG(
"should toggle mode\n");
1163 DLOG(
"should switch mode to %s\n", floating_mode);
1164 if (strcmp(floating_mode,
"enable") == 0) {
1172 cmd_output->needs_tree_render =
true;
1182 DLOG(
"should move workspace to output %s\n", name);
1191 ELOG(
"Failed to move workspace to output.\n");
1197 cmd_output->needs_tree_render =
true;
1209 LOG(
"splitting in direction %c\n", direction[0]);
1219 cmd_output->needs_tree_render =
true;
1229 if (kill_mode_str == NULL)
1230 kill_mode_str =
"window";
1233 DLOG(
"kill_mode=%s\n", kill_mode_str);
1236 if (strcmp(kill_mode_str,
"window") == 0)
1238 else if (strcmp(kill_mode_str,
"client") == 0)
1241 ELOG(
"BUG: called with kill_mode=%s\n", kill_mode_str);
1256 cmd_output->needs_tree_render =
true;
1266 bool no_startup_id = (nosn != NULL);
1268 DLOG(
"should execute %s, no_startup_id = %d\n", command, no_startup_id);
1280 DLOG(
"direction = *%s*\n", direction);
1282 if (strcmp(direction,
"left") == 0)
1284 else if (strcmp(direction,
"right") == 0)
1286 else if (strcmp(direction,
"up") == 0)
1288 else if (strcmp(direction,
"down") == 0)
1291 ELOG(
"Invalid focus direction (%s)\n", direction);
1296 cmd_output->needs_tree_render =
true;
1306 DLOG(
"window_mode = %s\n", window_mode);
1311 if (strcmp(window_mode,
"mode_toggle") == 0) {
1313 if (current != NULL && current->
type == CT_FLOATING_CON)
1314 window_mode =
"tiling";
1316 window_mode =
"floating";
1319 if ((strcmp(window_mode,
"floating") == 0 && current->
type != CT_FLOATING_CON) ||
1320 (strcmp(window_mode,
"tiling") == 0 && current->
type == CT_FLOATING_CON))
1328 cmd_output->needs_tree_render =
true;
1338 DLOG(
"level = %s\n", level);
1339 bool success =
false;
1343 if (strcmp(level,
"parent") == 0) {
1348 ELOG(
"'focus parent': Currently in fullscreen, not going up\n");
1356 cmd_output->needs_tree_render = success;
1369 ELOG(
"You have to specify which window/container should be focused.\n");
1370 ELOG(
"Example: [class=\"urxvt\" title=\"irssi\"] focus\n");
1372 yerror(
"You have to specify which window/container should be focused");
1389 LOG(
"Cannot change focus while in fullscreen mode (fullscreen rules).\n");
1395 if (ws == __i3_scratch) {
1422 LOG(
"focusing %p / %s\n", current->
con, current->
con->
name);
1428 LOG(
"WARNING: Your criteria for the focus command matches %d containers, "
1429 "while only exactly one container can be focused at a time.\n",
1432 cmd_output->needs_tree_render =
true;
1444 DLOG(
"%s fullscreen, mode = %s\n", action, fullscreen_mode);
1451 if (strcmp(action,
"toggle") == 0) {
1453 }
else if (strcmp(action,
"enable") == 0) {
1455 }
else if (strcmp(action,
"disable") == 0) {
1460 cmd_output->needs_tree_render =
true;
1471 int px = atoi(move_px);
1479 DLOG(
"moving in direction %s, px %s\n", direction, move_px);
1481 DLOG(
"floating move with %d pixels\n", px);
1483 if (strcmp(direction,
"left") == 0) {
1485 }
else if (strcmp(direction,
"right") == 0) {
1487 }
else if (strcmp(direction,
"up") == 0) {
1489 }
else if (strcmp(direction,
"down") == 0) {
1495 cmd_output->needs_tree_render =
true;
1500 if (
focused != initially_focused)
1512 if (strcmp(layout_str,
"stacking") == 0)
1513 layout_str =
"stacked";
1517 if (strcmp(layout_str,
"default") == 0)
1519 else if (strcmp(layout_str,
"stacked") == 0)
1521 else if (strcmp(layout_str,
"tabbed") == 0)
1523 else if (strcmp(layout_str,
"splitv") == 0)
1525 else if (strcmp(layout_str,
"splith") == 0)
1528 ELOG(
"Unknown layout \"%s\", this is a mismatch between code and parser spec.\n", layout_str);
1532 DLOG(
"changing layout to %s (%d)\n", layout_str, layout);
1544 cmd_output->needs_tree_render =
true;
1556 if (toggle_mode == NULL)
1557 toggle_mode =
"default";
1559 DLOG(
"toggling layout (mode = %s)\n", toggle_mode);
1571 cmd_output->needs_tree_render =
true;
1581 LOG(
"Exiting due to user command.\n");
1584 xcb_disconnect(
conn);
1614 LOG(
"restarting i3\n");
1631 LOG(
"opening new container\n");
1640 y(integer, (
long int)con);
1643 cmd_output->needs_tree_render =
true;
1653 DLOG(
"name = %s\n", name);
1658 Output *current_output = NULL;
1663 assert(current_output != NULL);
1668 LOG(
"No such output found.\n");
1683 cmd_output->needs_tree_render =
true;
1695 bool has_error =
false;
1702 ELOG(
"Cannot change position. The window/container is not floating\n");
1705 yerror(
"Cannot change position of a window/container because it is not floating.");
1712 if (strcmp(method,
"absolute") == 0) {
1716 DLOG(
"moving to absolute position %d %d\n", x, y);
1718 cmd_output->needs_tree_render =
true;
1721 if (strcmp(method,
"position") == 0) {
1724 DLOG(
"moving to position %d %d\n", x, y);
1743 ELOG(
"Cannot change position. The window/container is not floating\n");
1744 yerror(
"Cannot change position. The window/container is not floating.");
1748 if (strcmp(method,
"absolute") == 0) {
1751 DLOG(
"moving to absolute center\n");
1756 cmd_output->needs_tree_render =
true;
1759 if (strcmp(method,
"position") == 0) {
1763 DLOG(
"moving to center\n");
1764 newrect.
x = wsrect->
width / 2 - newrect.
width / 2;
1779 DLOG(
"should move window to scratchpad\n");
1789 cmd_output->needs_tree_render =
true;
1799 DLOG(
"should show scratchpad window\n");
1811 cmd_output->needs_tree_render =
true;
1821 if (strncasecmp(new_name,
"__", strlen(
"__")) == 0) {
1822 LOG(
"Cannot rename workspace to \"%s\": names starting with __ are i3-internal.", new_name);
1827 LOG(
"Renaming workspace \"%s\" to \"%s\"\n", old_name, new_name);
1829 LOG(
"Renaming current workspace to \"%s\"\n", new_name);
1832 Con *output, *workspace = NULL;
1836 !strcasecmp(child->name, old_name));
1839 old_name = workspace->
name;
1843 yerror(
"Old workspace \"%s\" not found", old_name);
1847 Con *check_dest = NULL;
1850 !strcasecmp(child->name, new_name));
1852 if (check_dest != NULL) {
1853 yerror(
"New workspace \"%s\" already exists", new_name);
1862 LOG(
"num = %d\n", workspace->
num);
1873 if (assignment->
output == NULL)
1881 if (previously_focused)
1890 cmd_output->needs_tree_render =
true;
1907 bool toggle =
false;
1908 if (strcmp(bar_mode,
"dock") == 0)
1910 else if (strcmp(bar_mode,
"hide") == 0)
1912 else if (strcmp(bar_mode,
"invisible") == 0)
1914 else if (strcmp(bar_mode,
"toggle") == 0)
1917 ELOG(
"Unknown bar mode \"%s\", this is a mismatch between code and parser spec.\n", bar_mode);
1921 bool changed_sth =
false;
1924 if (bar_id && strcmp(current->
id, bar_id) != 0)
1928 mode = (current->
mode + 1) % 2;
1930 DLOG(
"Changing bar mode of bar_id '%s' to '%s (%d)'\n", current->
id, bar_mode, mode);
1931 current->
mode = mode;
1938 if (bar_id && !changed_sth) {
1939 DLOG(
"Changing bar mode of bar_id %s failed, bar_id not found.\n", bar_id);
1951 int hidden_state = S_SHOW;
1952 bool toggle =
false;
1953 if (strcmp(bar_hidden_state,
"hide") == 0)
1954 hidden_state = S_HIDE;
1955 else if (strcmp(bar_hidden_state,
"show") == 0)
1956 hidden_state = S_SHOW;
1957 else if (strcmp(bar_hidden_state,
"toggle") == 0)
1960 ELOG(
"Unknown bar state \"%s\", this is a mismatch between code and parser spec.\n", bar_hidden_state);
1964 bool changed_sth =
false;
1967 if (bar_id && strcmp(current->
id, bar_id) != 0)
1973 DLOG(
"Changing bar hidden_state of bar_id '%s' to '%s (%d)'\n", current->
id, bar_hidden_state, hidden_state);
1981 if (bar_id && !changed_sth) {
1982 DLOG(
"Changing bar hidden_state of bar_id %s failed, bar_id not found.\n", bar_id);
1995 if (strcmp(bar_type,
"mode") == 0)
1997 else if (strcmp(bar_type,
"hidden_state") == 0)
2000 ELOG(
"Unknown bar option type \"%s\", this is a mismatch between code and parser spec.\n", bar_type);
2016 if (!strcmp(argument,
"toggle"))
2019 else if (!strcmp(argument,
"on"))
2021 else if (!strcmp(argument,
"off"))
2027 LOG(
"Restarting shm logging...\n");
2035 LOG(
"%s shm logging\n",
shmlog_size > 0 ?
"Enabling" :
"Disabling");
2048 if (!strcmp(argument,
"toggle")) {
2049 LOG(
"%s debug logging\n", logging ?
"Disabling" :
"Enabling");
2051 }
else if (!strcmp(argument,
"on") && !logging) {
2052 LOG(
"Enabling debug logging\n");
2054 }
else if (!strcmp(argument,
"off") && logging) {
2055 LOG(
"Disabling debug logging\n");
enum Con::@20 scratchpad_state
void tree_next(char way, orientation_t orientation)
Changes focus in the given way (next/previous) and given orientation (horizontal/vertical).
static void nagbar_cleanup(EV_P_ ev_cleanup *watcher, int revent)
long ws_name_to_number(const char *name)
Parses the workspace name as a number.
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...
bool floating_maybe_reassign_ws(Con *con)
Checks if con’s coordinates are within its workspace and re-assigns it to the actual workspace if no...
void ipc_shutdown(void)
Calls shutdown() on each socket and closes it.
void con_set_layout(Con *con, layout_t layout)
This function changes the layout of a given container.
Output * get_output_by_name(const char *name)
Returns the output with the given name if it is active (!) or NULL.
bool con_is_floating(Con *con)
Returns true if the node is floating.
bool get_debug_logging(void)
Checks if debug logging is active.
json_content_t json_determine_content(const char *filename)
fullscreen_mode_t
Fullscreen modes.
void scratchpad_move(Con *con)
Moves the specified window to the __i3_scratch workspace, making it floating and setting the appropri...
void con_enable_fullscreen(Con *con, fullscreen_mode_t fullscreen_mode)
Enables fullscreen mode for the given container, if necessary.
#define TAILQ_REMOVE(head, elm, field)
void con_attach(Con *con, Con *parent, bool ignore_focus)
Attaches the given container to the given parent.
void exec_i3_utility(char *name, char *argv[])
exec()s an i3 utility, for example the config file migration script or i3-nagbar. ...
void cmd_scratchpad_show(I3_CMD)
Implementation of 'scratchpad show'.
Output * get_output_from_string(Output *current_output, const char *output_str)
Returns an 'output' corresponding to one of left/right/down/up or a specific output name...
void cmd_move_con_to_workspace_name(I3_CMD, char *name)
Implementation of 'move [window|container] [to] workspace '.
Con * con_get_workspace(Con *con)
Gets the workspace container this node is on.
static bool cmd_resize_tiling_direction(I3_CMD, Con *current, char *way, char *direction, int ppt)
Stores which workspace (by name or number) goes to which output.
Con * workspace_next(void)
Returns the next workspace.
static bool maybe_back_and_forth(struct CommandResultIR *cmd_output, char *name)
Stores a rectangle, for example the size of a window, the child window etc.
bool workspace_is_visible(Con *ws)
Returns true if the workspace is currently visible.
void load_configuration(xcb_connection_t *conn, const char *override_configpath, bool reload)
Reads the configuration from ~/.i3/config or /etc/i3/config if not found.
void startup_sequence_rename_workspace(char *old_name, char *new_name)
Renames workspaces that are mentioned in the startup sequences.
bool cmd_bar_hidden_state(char *bar_hidden_state, char *bar_id)
enum Barconfig::@5 mode
Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mo...
void con_detach(Con *con)
Detaches the given container from its current parent.
void cmd_shmlog(I3_CMD, char *argument)
void cmd_resize(I3_CMD, char *way, char *direction, char *resize_px, char *resize_ppt)
Implementation of 'resize grow|shrink
[ px] [or ppt]'.
Con * workspace_prev_on_output(void)
Returns the previous workspace on the same output.
void cmd_nop(I3_CMD, char *comment)
Implementation of 'nop '.
void con_disable_fullscreen(Con *con)
Disables fullscreen mode for the given container, if necessary.
void floating_disable(Con *con, bool automatic)
Disables floating mode for the given container by re-attaching the container to its old parent...
void ewmh_update_desktop_names(void)
Updates _NET_DESKTOP_NAMES: "The names of all virtual desktops.
static void cmd_resize_floating(I3_CMD, char *way, char *direction, Con *floating_con, int px)
void workspace_show(Con *workspace)
Switches to the given workspace.
Con * con_descend_focused(Con *con)
Returns the focused con inside this client, descending the tree as far as possible.
bool con_accepts_window(Con *con)
Returns true if this node accepts a window (if the node swallows windows, it might already have swall...
struct all_cons_head all_cons
void cmd_criteria_match_windows(I3_CMD)
A match specification just finished (the closing square bracket was found), so we filter the list of ...
struct regex * window_role
Con * tree_open_con(Con *con, i3Window *window)
Opens an empty container in the current container.
void cmd_floating(I3_CMD, char *floating_mode)
Implementation of 'floating enable|disable|toggle'.
void ewmh_update_desktop_viewport(void)
Updates _NET_DESKTOP_VIEWPORT, which is an array of pairs of cardinals that define the top left corne...
void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool dont_warp)
Moves the given container to the currently focused container on the given workspace.
void cmd_move_window_to_center(I3_CMD, char *method)
Implementation of 'move [window|container] [to] [absolute] position center.
void cmd_move_direction(I3_CMD, char *direction, char *move_px)
Implementation of 'move
[ [px]]'.
struct ev_loop * main_loop
#define TAILQ_FIRST(head)
void cmd_move_window_to_position(I3_CMD, char *method, char *cx, char *cy)
Implementation of 'move [window|container] [to] [absolute] position
[px] [px]...
bool con_has_children(Con *con)
Returns true if this node has regular or floating children.
static Output * get_output_of_con(Con *con)
void purge_zerobyte_logfile(void)
Deletes the unused log files.
static Con * maybe_auto_back_and_forth_workspace(Con *workspace)
void cmd_focus(I3_CMD)
Implementation of 'focus'.
void cmd_workspace(I3_CMD, char *which)
Implementation of 'workspace next|prev|next_on_output|prev_on_output'.
bool level_up(void)
Moves focus one level up.
bool workspace_auto_back_and_forth
Automatic workspace back and forth switching.
An Output is a physical output on your graphics driver.
layout_t
Container layouts.
void cmd_focus_window_mode(I3_CMD, char *window_mode)
Implementation of 'focus tiling|floating|mode_toggle'.
void floating_reposition(Con *con, Rect newrect)
Repositions the CT_FLOATING_CON to have the coordinates specified by newrect, but only if the coordin...
#define TAILQ_NEXT(elm, field)
void tree_move(Con *con, int direction)
Moves the given container in the given direction (TOK_LEFT, TOK_RIGHT, TOK_UP, TOK_DOWN from cmdparse...
void tree_append_json(Con *con, const char *filename, char **errormsg)
border_style_t border_style
void workspace_show_by_name(const char *num)
Looks up the workspace by name and switches to it.
void update_barconfig()
Sends the current bar configuration as an event to all barconfig_update listeners.
void cmd_split(I3_CMD, char *direction)
Implementation of 'split v|h|vertical|horizontal'.
void i3_restart(bool forget_layout)
Restart i3 in-place appends -a to argument list to disable autostart.
void con_set_border_style(Con *con, int border_style, int border_width)
Sets the given border style on con, correctly keeping the position/size of a floating window...
pid_t command_error_nagbar_pid
void switch_mode(const char *new_mode)
Switches the key bindings to the given mode, if the mode exists.
static Match current_match
void cmd_move_con_to_workspace_number(I3_CMD, char *which)
Implementation of 'move [window|container] [to] workspace number '.
pid_t config_error_nagbar_pid
void cmd_mark(I3_CMD, char *mark)
Implementation of 'mark '.
struct regex * regex_new(const char *pattern)
Creates a new 'regex' struct containing the given pattern and a PCRE compiled regular expression...
void cmd_border(I3_CMD, char *border_style_str, char *border_width)
Implementation of 'border normal|none|1pixel|toggle'.
void cmd_layout(I3_CMD, char *layout_str)
Implementation of 'layout default|stacked|stacking|tabbed|splitv|splith'.
Con * workspace_back_and_forth_get(void)
Returns the previously focused workspace con, or NULL if unavailable.
void cmd_open(I3_CMD)
Implementation of 'open'.
bool cmd_bar_mode(char *bar_mode, char *bar_id)
int sasprintf(char **strp, const char *fmt,...)
Safe-wrapper around asprintf which exits if it returns -1 (meaning that there is no more memory avail...
void tree_split(Con *con, orientation_t orientation)
Splits (horizontally or vertically) the given container by creating a new container which contains th...
void cmd_criteria_add(I3_CMD, char *ctype, char *cvalue)
Interprets a ctype=cvalue pair and adds it to the current match specification.
void cmd_mode(I3_CMD, char *mode)
Implementation of 'mode '.
void cmd_move_con_to_output(I3_CMD, char *name)
Implementation of 'move [window|container] [to] output '.
bool match_matches_window(Match *match, i3Window *window)
Check if a match data structure matches the given window.
void floating_check_size(Con *floating_con)
Called when a floating window is created or resized.
Con * con_get_fullscreen_con(Con *con, fullscreen_mode_t fullscreen_mode)
Returns the first fullscreen node below this node.
bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent, bool force_set_focus)
Closes the given container including all children.
void workspace_back_and_forth(void)
Focuses the previously focused workspace.
Con * con
Pointer to the Con which represents this output.
char * id
Automatically generated ID for this bar config.
int num
the workspace number, if this Con is of type CT_WORKSPACE and the workspace is not a named workspace ...
static bool cmd_resize_tiling_width_height(I3_CMD, Con *current, char *way, char *direction, int ppt)
void kill_nagbar(pid_t *nagbar_pid, bool wait_for_it)
Kills the i3-nagbar process, if *nagbar_pid != -1.
void cmd_rename_workspace(I3_CMD, char *old_name, char *new_name)
Implementation of 'rename workspace to '.
void ewmh_update_current_desktop(void)
Updates _NET_CURRENT_DESKTOP with the current desktop number.
bool level_down(void)
Moves focus one level down.
bool con_fullscreen_permits_focusing(Con *con)
Returns true if changing the focus to con would be allowed considering the fullscreen focus constrain...
void con_focus(Con *con)
Sets input focus to the given container.
void cmd_workspace_back_and_forth(I3_CMD)
Implementation of 'workspace back_and_forth'.
#define TAILQ_EMPTY(head)
int con_num_children(Con *con)
Returns the number of children of this container.
void cmd_move_con_to_workspace(I3_CMD, char *which)
Implementation of 'move [window|container] [to] workspace next|prev|next_on_output|prev_on_output'.
const int default_shmlog_size
void cmd_move_workspace_to_output(I3_CMD, char *name)
Implementation of 'move workspace to [output] '.
static bool definitelyGreaterThan(float a, float b, float epsilon)
void restore_open_placeholder_windows(Con *parent)
Open placeholder windows for all children of parent.
char * resolve_tilde(const char *path)
This function resolves ~ in pathnames.
enum Window::@11 dock
Whether the window says it is a dock window.
#define TAILQ_ENTRY(type)
void scratchpad_show(Con *con)
Either shows the top-most scratchpad window (con == NULL) or shows the specified con (if it is scratc...
#define I3_CMD
The beginning of the prototype for every cmd_ function.
static void nagbar_exited(EV_P_ ev_child *watcher, int revents)
#define GREP_FIRST(dest, head, condition)
orientation_t con_orientation(Con *con)
Returns the orientation of the given container (for stacked containers, vertical orientation is used ...
A 'Con' represents everything from the X11 root window down to a single X11 window.
void cmd_focus_direction(I3_CMD, char *direction)
Implementation of 'focus left|right|up|down'.
enum Barconfig::@6 hidden_state
void ipc_send_workspace_event(const char *change, Con *current, Con *old)
For the workspace events we send, along with the usual "change" field, also the workspace container i...
void cmd_append_layout(I3_CMD, char *path)
Implementation of 'append_layout
'.
Con * workspace_get(const char *num, bool *created)
Returns a pointer to the workspace with the given number (starting at 0), creating the workspace if n...
void cmd_focus_output(I3_CMD, char *name)
Implementation of 'focus output
void cmd_layout_toggle(I3_CMD, char *toggle_mode)
Implementation of 'layout toggle [all|split]'.
Con * workspace_prev(void)
Returns the previous workspace.
#define ysuccess(success)
void cmd_reload(I3_CMD)
Implementation of 'reload'.
void con_toggle_layout(Con *con, const char *toggle_mode)
This function toggles the layout of a given container.
bool resize_find_tiling_participants(Con **current, Con **other, direction_t direction)
bool workspace_move_to_output(Con *ws, char *name)
Move the given workspace to the specified output.
#define TAILQ_INSERT_TAIL(head, elm, field)
void cmd_exit(I3_CMD)
Implementation of 'exit'.
Con * workspace_next_on_output(void)
Returns the next workspace on the same output.
void cmd_exec(I3_CMD, char *nosn, char *command)
Implementation of 'exec [–no-startup-id] '.
void cmd_workspace_number(I3_CMD, char *which)
Implementation of 'workspace number '.
bool regex_matches(struct regex *regex, const char *input)
Checks if the given regular expression matches the given input and returns true if it does...
bool match_is_empty(Match *match)
Check if a match is empty.
void cmd_bar(I3_CMD, char *bar_type, char *bar_value, char *bar_id)
Implementation of 'bar (hidden_state hide|show|toggle)|(mode dock|hide|invisible|toggle) []'...
typedef TAILQ_HEAD(owindows_head, owindow)
struct barconfig_head barconfigs
void cmd_criteria_init(I3_CMD)
Initializes the specified 'Match' data structure and the initial state of commands.c for matching target windows of a command.
void init_logging(void)
Initializes logging by creating an error logfile in /tmp (or XDG_RUNTIME_DIR, see get_process_filenam...
Con * output_get_content(Con *output)
Returns the output container below the given output container.
Con * con_get_output(Con *con)
Gets the output container (first container with CT_OUTPUT in hierarchy) this node is on...
void cmd_workspace_name(I3_CMD, char *name)
Implementation of 'workspace '.
Con * con_inside_floating(Con *con)
Checks if the given container is either floating or inside some floating container.
void start_application(const char *command, bool no_startup_id)
Starts the given application by passing it through a shell.
void floating_enable(Con *con, bool automatic)
Enables floating mode for the given container by detaching it from its parent, creating a new contain...
void * smalloc(size_t size)
Safe-wrapper around malloc which exits if malloc returns NULL (meaning that there is no more memory a...
void x_set_i3_atoms(void)
Sets up i3 specific atoms (I3_SOCKET_PATH and I3_CONFIG_PATH)
void update_shmlog_atom()
Set up the SHMLOG_PATH atom.
void cmd_kill(I3_CMD, char *kill_mode_str)
Implementation of 'kill [window|client]'.
#define HANDLE_EMPTY_MATCH
When the command did not include match criteria (!), we use the currently focused container...
void cmd_focus_level(I3_CMD, char *level)
Implementation of 'focus parent|child'.
#define TAILQ_FOREACH(var, head, field)
void cmd_fullscreen(I3_CMD, char *action, char *fullscreen_mode)
Implementation of 'fullscreen [enable|disable|toggle] [global]'.
void cmd_move_scratchpad(I3_CMD)
Implementation of 'move scratchpad'.
void toggle_floating_mode(Con *con, bool automatic)
Calls floating_enable() for tiling containers and floating_disable() for floating containers...
Holds the status bar configuration (i3bar).
void cmd_move_con_to_workspace_back_and_forth(I3_CMD)
Implementation of 'move [window|container] [to] workspace back_and_forth'.
void cmd_restart(I3_CMD)
Implementation of 'restart'.
void cmd_unmark(I3_CMD, char *mark)
Implementation of 'unmark [mark]'.
void tree_close_con(kill_window_t kill_window)
Closes the current container using tree_close().
struct ws_assignments_head ws_assignments
#define yerror(format,...)
void cmd_debuglog(I3_CMD, char *argument)
void match_init(Match *match)
void con_toggle_fullscreen(Con *con, int fullscreen_mode)
Toggles fullscreen mode for the given container.
void set_debug_logging(const bool _debug_logging)
Set debug logging.
void render_con(Con *con, bool render_fullscreen)
"Renders" the given container (and its children), meaning that all rects are updated correctly...
void match_free(Match *match)
Frees the given match.