From 9a58c1fcaaf47e2d9bf32097fa129adfe838a3b5 Mon Sep 17 00:00:00 2001 From: Jose Pereira Date: Sun, 1 Apr 2012 15:07:15 +0100 Subject: [PATCH] Added option to select primary display on tray_output --- docs/userguide | 10 +++++++++- i3bar/include/outputs.h | 1 + i3bar/src/outputs.c | 16 ++++++++++------ i3bar/src/xcb.c | 9 ++++++--- src/ipc.c | 3 +++ 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/docs/userguide b/docs/userguide index 957d0c7f..ad7c6195 100644 --- a/docs/userguide +++ b/docs/userguide @@ -964,7 +964,7 @@ you can turn off the functionality entirely. *Syntax*: ------------------------- -tray_output +tray_output ------------------------- *Example*: @@ -974,12 +974,20 @@ bar { tray_output none } +# show tray icons on the primary monitor +tray_output primary + # show tray icons on the big monitor bar { tray_output HDMI2 } ------------------------- +Note that you might not have a primary output configured yet. To do so, run: +------------------------- +xrandr --output --primary +------------------------- + === Font Specifies the font (again, X core font, not Xft, just like in i3) to be used in diff --git a/i3bar/include/outputs.h b/i3bar/include/outputs.h index 6501c318..f9ddd54b 100644 --- a/i3bar/include/outputs.h +++ b/i3bar/include/outputs.h @@ -40,6 +40,7 @@ i3_output* get_output_by_name(char* name); struct i3_output { char* name; /* Name of the output */ bool active; /* If the output is active */ + bool primary; /* If it is the primary output */ int ws; /* The number of the currently visible ws */ rect rect; /* The rect (relative to the root-win) */ diff --git a/i3bar/src/outputs.c b/i3bar/src/outputs.c index 9dc5cab8..83a4c248 100644 --- a/i3bar/src/outputs.c +++ b/i3bar/src/outputs.c @@ -45,15 +45,19 @@ static int outputs_null_cb(void *params_) { static int outputs_boolean_cb(void *params_, int val) { struct outputs_json_params *params = (struct outputs_json_params*) params_; - if (strcmp(params->cur_key, "active")) { - return 0; + if (!strcmp(params->cur_key, "active")) { + params->outputs_walk->active = val; + FREE(params->cur_key); + return 1; } - params->outputs_walk->active = val; - - FREE(params->cur_key); + if (!strcmp(params->cur_key, "primary")) { + params->outputs_walk->primary = val; + FREE(params->cur_key); + return 1; + } - return 1; + return 0; } /* diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index 4d4dd384..a3f0dda8 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -450,9 +450,12 @@ static void handle_client_message(xcb_client_message_event_t* event) { SLIST_FOREACH(walk, outputs, slist) { if (!walk->active) continue; - if (config.tray_output && - strcasecmp(walk->name, config.tray_output) != 0) - continue; + if (config.tray_output) { + if ((strcasecmp(walk->name, config.tray_output) != 0) && + (!walk->primary || strcasecmp("primary", config.tray_output) != 0)) + continue; + } + DLOG("using output %s\n", walk->name); output = walk; } diff --git a/src/ipc.c b/src/ipc.c index 40ad8684..5e91e21d 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -443,6 +443,9 @@ IPC_HANDLER(get_outputs) { ystr("active"); y(bool, output->active); + ystr("primary"); + y(bool, output->primary); + ystr("rect"); y(map_open); ystr("x"); -- 2.39.5