- fprintf(stderr, "i3-dump-log: ERROR: i3 is running, but SHM logging is not enabled.\n\n");
- if (!is_debug_build()) {
+ fprintf(stderr, "i3-dump-log: ERROR: i3 is running, but SHM logging is not enabled. Enabling SHM log until cancelled\n\n");
+ ipcfd = ipc_connect(NULL);
+ const char *enablecmd = "debuglog on; shmlog 5242880";
+ if (ipc_send_message(ipcfd, strlen(enablecmd),
+ I3_IPC_MESSAGE_TYPE_COMMAND, (uint8_t *)enablecmd) != 0)
+ err(EXIT_FAILURE, "IPC send");
+ /* By the time we receive a reply, I3_SHMLOG_PATH is set: */
+ uint32_t reply_length = 0;
+ uint8_t *reply = NULL;
+ if (ipc_recv_message(ipcfd, I3_IPC_REPLY_TYPE_COMMAND,
+ &reply_length, &reply) != 0) {
+ err(EXIT_FAILURE, "IPC recv");
+ }
+ free(reply);
+
+ atexit(disable_shmlog);
+
+ /* Retry: */
+ shmname = root_atom_contents("I3_SHMLOG_PATH", NULL, 0);
+ if (shmname == NULL && !is_debug_build()) {