make i3bar use libi3’s root_atom_contents()

This removes code duplication, which will be useful for a subsequent
commit.

Furthermore, we now don’t open X11 connections unnecessarily in some
corner cases.
This commit is contained in:
Michael Stapelberg
2013-11-22 15:48:45 +01:00
parent ca39289e3e
commit d3beff2339
9 changed files with 36 additions and 48 deletions

View File

@ -68,11 +68,11 @@ static yajl_callbacks version_callbacks = {
*
*/
void display_running_version(void) {
char *socket_path = root_atom_contents("I3_SOCKET_PATH");
char *socket_path = root_atom_contents("I3_SOCKET_PATH", conn, conn_screen);
if (socket_path == NULL)
exit(EXIT_SUCCESS);
char *pid_from_atom = root_atom_contents("I3_PID");
char *pid_from_atom = root_atom_contents("I3_PID", conn, conn_screen);
if (pid_from_atom == NULL) {
/* If I3_PID is not set, the running version is older than 4.2-200. */
printf("\nRunning version: < 4.2-200\n");