Skip to content
This repository has been archived by the owner on Nov 7, 2022. It is now read-only.

Commit

Permalink
Add proper return code for i3-msg
Browse files Browse the repository at this point in the history
  • Loading branch information
NilsIrl committed Feb 21, 2019
1 parent e2d6117 commit 72ccd34
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion i3-msg/main.c
Expand Up @@ -67,6 +67,7 @@ typedef struct reply_t {
char *errorposition;
} reply_t;

static int exit_code = 0;
static reply_t last_reply;

static int reply_boolean_cb(void *params, int val) {
Expand Down Expand Up @@ -100,6 +101,7 @@ static int reply_end_map_cb(void *params) {
fprintf(stderr, "ERROR: %s\n", last_reply.errorposition);
}
fprintf(stderr, "ERROR: %s\n", last_reply.error);
exit_code = 2;
}
return 1;
}
Expand Down Expand Up @@ -326,5 +328,5 @@ int main(int argc, char *argv[]) {

close(sockfd);

return 0;
return exit_code;
}
9 changes: 9 additions & 0 deletions man/i3-msg.man
Expand Up @@ -90,6 +90,15 @@ See the -m option for continuous monitoring.
i3-msg is a sample implementation for a client using the unix socket IPC
interface to i3.

=== Exit status:

0:
if OK,
1:
if invalid syntax or unable to connect to ipc-socket
2:
if i3 returned an error processing your command(s)

== EXAMPLES

------------------------------------------------
Expand Down

0 comments on commit 72ccd34

Please sign in to comment.