aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/tray
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-01-13 12:06:35 -0500
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-01-13 12:06:35 -0500
commit50d36ef238182c33bca8dfc01dd56957e31ff6bd (patch)
tree9eaac98af416b7a0a46e70a254561bdb968dfe25 /swaybar/tray
parentMerge pull request #3411 from RedSoxFan/fix-brace-detect-seeking (diff)
downloadsway-50d36ef238182c33bca8dfc01dd56957e31ff6bd.tar.gz
sway-50d36ef238182c33bca8dfc01dd56957e31ff6bd.tar.zst
sway-50d36ef238182c33bca8dfc01dd56957e31ff6bd.zip
swaybar: allow identifiers for output and tray
This allows `bar output` and `bar tray_output` to specify an output identifier. Output names should still work as well. This parses the output identifier from the xdg_output description, which wlroots currently sets to `make model serial (name)`. Since this could change in the future, all identifier comparisons are guarded by NULL-checks in case the description cannot be parsed to an identifier.
Diffstat (limited to 'swaybar/tray')
-rw-r--r--swaybar/tray/tray.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/swaybar/tray/tray.c b/swaybar/tray/tray.c
index 0c3517cb..d5d0c84e 100644
--- a/swaybar/tray/tray.c
+++ b/swaybar/tray/tray.c
@@ -101,13 +101,17 @@ void tray_in(int fd, short mask, void *data) {
101} 101}
102 102
103static int cmp_output(const void *item, const void *cmp_to) { 103static int cmp_output(const void *item, const void *cmp_to) {
104 return strcmp(item, cmp_to); 104 const struct swaybar_output *output = cmp_to;
105 if (output->identifier && strcmp(item, output->identifier) == 0) {
106 return 0;
107 }
108 return strcmp(item, output->name);
105} 109}
106 110
107uint32_t render_tray(cairo_t *cairo, struct swaybar_output *output, double *x) { 111uint32_t render_tray(cairo_t *cairo, struct swaybar_output *output, double *x) {
108 struct swaybar_config *config = output->bar->config; 112 struct swaybar_config *config = output->bar->config;
109 if (config->tray_outputs) { 113 if (config->tray_outputs) {
110 if (list_seq_find(config->tray_outputs, cmp_output, output->name) == -1) { 114 if (list_seq_find(config->tray_outputs, cmp_output, output) == -1) {
111 return 0; 115 return 0;
112 } 116 }
113 } // else display on all 117 } // else display on all