i3bar: Introducing noninteractive mode
Patch status: rejected
Patch by Tony Crisci
Long description:
When the `--noninteractive` flag is passed to i3bar, it will ignore mouse events.
To apply this patch, use:
curl http://cr.i3wm.org/patch/296/raw.patch | git am
b/i3bar/include/config.h
| 17 |
@@ -25,6 +25,7 @@ typedef struct config_t {
|
| 18 |
struct xcb_color_strings_t colors; |
| 19 |
bool disable_binding_mode_indicator; |
| 20 |
bool disable_ws; |
| 21 |
+ bool noninteractive; |
| 22 |
char *bar_id; |
| 23 |
char *command; |
| 24 |
char *fontname; |
b/i3bar/src/main.c
| 29 |
@@ -57,6 +57,7 @@ void print_usage(char *elf_name) {
|
| 30 |
printf("\n");
|
| 31 |
printf("-b, --bar_id <bar_id>\tBar ID for which to get the configuration\n");
|
| 32 |
printf("-s, --socket <sock_path>\tConnect to i3 via <sock_path>\n");
|
| 33 |
+ printf("-n, --noninteractive\tBar will not respond to mouse interaction\n");
|
| 34 |
printf("-h, --help Display this help-message and exit\n");
|
| 35 |
printf("-v, --version Display version number and exit\n");
|
| 36 |
printf("\n");
|
| 37 |
@@ -98,12 +99,13 @@ int main(int argc, char **argv) {
|
| 38 |
static struct option long_opt[] = {
|
| 39 |
{ "socket", required_argument, 0, 's' },
|
| 40 |
{ "bar_id", required_argument, 0, 'b' },
|
| 41 |
+ { "noninteractive", no_argument, 0, 'n' },
|
| 42 |
{ "help", no_argument, 0, 'h' },
|
| 43 |
{ "version", no_argument, 0, 'v' },
|
| 44 |
{ NULL, 0, 0, 0}
|
| 45 |
}; |
| 46 |
|
| 47 |
- while ((opt = getopt_long(argc, argv, "b:s:hv", long_opt, &option_index)) != -1) {
|
| 48 |
+ while ((opt = getopt_long(argc, argv, "b:s:hvn", long_opt, &option_index)) != -1) {
|
| 49 |
switch (opt) {
|
| 50 |
case 's': |
| 51 |
socket_path = expand_path(optarg); |
| 52 |
@@ -115,6 +117,9 @@ int main(int argc, char **argv) {
|
| 53 |
case 'b': |
| 54 |
config.bar_id = sstrdup(optarg); |
| 55 |
break; |
| 56 |
+ case 'n': |
| 57 |
+ config.noninteractive = true; |
| 58 |
+ break; |
| 59 |
default: |
| 60 |
print_usage(argv[0]); |
| 61 |
exit(EXIT_SUCCESS); |
b/i3bar/src/xcb.c
| 66 |
@@ -791,7 +791,11 @@ void xcb_chk_cb(struct ev_loop *loop, ev_check *watcher, int revents) {
|
| 67 |
break; |
| 68 |
case XCB_BUTTON_PRESS: |
| 69 |
/* Button-press-events are mouse-buttons clicked on one of our bars */ |
| 70 |
- handle_button((xcb_button_press_event_t*) event); |
| 71 |
+ if (config.noninteractive) |
| 72 |
+ DLOG("Noninteractive mode: ignoring button press.\n");
|
| 73 |
+ else |
| 74 |
+ handle_button((xcb_button_press_event_t*) event); |
| 75 |
+ |
| 76 |
break; |
| 77 |
case XCB_CLIENT_MESSAGE: |
| 78 |
/* Client messages are used for client-to-client communication, for |