Improve the main error message of i3-dump-log
Michael Stapelberg
12 years ago
54 | 54 | } |
55 | 55 | |
56 | 56 | char *shmname = root_atom_contents("I3_SHMLOG_PATH"); |
57 | if (shmname == NULL) | |
57 | if (shmname == NULL) { | |
58 | /* Something failed. Let’s invest a little effort to find out what it | |
59 | * is. This is hugely helpful for users who want to debug i3 but are | |
60 | * not used to the procedure yet. */ | |
61 | xcb_connection_t *conn; | |
62 | int screen; | |
63 | if ((conn = xcb_connect(NULL, &screen)) == NULL || | |
64 | xcb_connection_has_error(conn)) { | |
65 | fprintf(stderr, "i3-dump-log: ERROR: Cannot connect to X11.\n\n"); | |
66 | if (getenv("DISPLAY") == NULL) { | |
67 | fprintf(stderr, "Your DISPLAY environment variable is not set.\n"); | |
68 | fprintf(stderr, "Are you running i3-dump-log via SSH or on a virtual console?\n"); | |
69 | fprintf(stderr, "Try DISPLAY=:0 i3-dump-log\n"); | |
70 | exit(1); | |
71 | } | |
72 | fprintf(stderr, "FYI: The DISPLAY environment variable is set to \"%s\".\n", getenv("DISPLAY")); | |
73 | exit(1); | |
74 | } | |
75 | if (root_atom_contents("I3_CONFIG_PATH") != NULL) { | |
76 | fprintf(stderr, "i3-dump-log: ERROR: i3 is running, but SHM logging is not enabled.\n\n"); | |
77 | if (!is_debug_build()) { | |
78 | fprintf(stderr, "You seem to be using a release version of i3:\n %s\n\n", I3_VERSION); | |
79 | fprintf(stderr, "Release versions do not use SHM logging by default,\ntherefore i3-dump-log does not work.\n\n"); | |
80 | fprintf(stderr, "Please follow this guide instead:\nhttp://i3wm.org/docs/debugging-release-version.html\n"); | |
81 | exit(1); | |
82 | } | |
83 | } | |
58 | 84 | errx(EXIT_FAILURE, "Cannot get I3_SHMLOG_PATH atom contents. Is i3 running on this display?"); |
85 | } | |
59 | 86 | |
60 | 87 | if (*shmname == '\0') |
61 | 88 | errx(EXIT_FAILURE, "Cannot dump log: SHM logging is disabled in i3."); |