diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e20c4b..762c37b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,9 +17,11 @@ * river: support for ‘layout’ events. * dwl: support for specifying name of tags ([#256][256]) * i3/sway: extend option `sort`; use `native` to sort numbered workspaces only. +* modules/dwl: handle the appid status ([#284][284]) [246]: https://codeberg.org/dnkl/yambar/issues/246 [256]: https://codeberg.org/dnkl/yambar/pulls/256 +[284]: https://codeberg.org/dnkl/yambar/pulls/284 ### Changed diff --git a/doc/yambar-modules-dwl.5.scd b/doc/yambar-modules-dwl.5.scd index 60656f4..289955a 100644 --- a/doc/yambar-modules-dwl.5.scd +++ b/doc/yambar-modules-dwl.5.scd @@ -8,7 +8,7 @@ dwl - This module provides information about dwl tags, and information. This module provides a map of each tags present in dwl. Each tags has its _id_, its _name_, its status (_selected_, _empty_, _urgent_) -and the global data like _title_, _fullscreen_, _floating_, +and the global data like _title_, _appid_, _fullscreen_, _floating_, _selmon_, and _layout_). The tags start a 1. For needs where you only want information about the global data and not the _tags_, there is a tag with the id _0_ that contains only the global data. @@ -44,6 +44,9 @@ Running multiple instances at the same time may result in | title : string : The currently focused window's title. +| appid +: string +: The currently focused window's application id. | fullscreen : bool : True if there is a fullscreen window in the current tag. diff --git a/modules/dwl.c b/modules/dwl.c index df3a000..a9a5bab 100644 --- a/modules/dwl.c +++ b/modules/dwl.c @@ -35,6 +35,7 @@ struct private /* dwl data */ char *title; + char *appid; bool fullscreen; bool floating; bool selmon; @@ -45,6 +46,7 @@ struct private enum LINE_MODE { LINE_MODE_0, LINE_MODE_TITLE, + LINE_MODE_APPID, LINE_MODE_FULLSCREEN, LINE_MODE_FLOATING, LINE_MODE_SELMON, @@ -94,6 +96,7 @@ content(struct module *module) struct tag_set tags = { .tags = (struct tag*[]){ tag_new_string(module, "title", private->title), + tag_new_string(module, "appid", private->appid), tag_new_bool(module, "fullscreen", private->fullscreen), tag_new_bool(module, "floating", private->floating), tag_new_bool(module, "selmon", private->selmon), @@ -104,7 +107,7 @@ content(struct module *module) tag_new_bool(module, "empty", it->item->empty), tag_new_bool(module, "urgent", it->item->urgent), }, - .count = 10, + .count = 11, }; exposable[i++] = private->label->instantiate(private->label, &tags); tag_set_destroy(&tags); @@ -114,6 +117,7 @@ content(struct module *module) struct tag_set tags = { .tags = (struct tag*[]){ tag_new_string(module, "title", private->title), + tag_new_string(module, "appid", private->appid), tag_new_bool(module, "fullscreen", private->fullscreen), tag_new_bool(module, "floating", private->floating), tag_new_bool(module, "selmon", private->selmon), @@ -124,7 +128,7 @@ content(struct module *module) tag_new_bool(module, "empty", true), tag_new_bool(module, "urgent", false), }, - .count = 10, + .count = 11, }; exposable[i++] = private->label->instantiate(private->label, &tags); tag_set_destroy(&tags); @@ -183,6 +187,12 @@ process_line(char *line, struct module *module) free(private->title); private->title = strdup(save_pointer); break; + } else if (strcmp(string, "appid") == 0) { + line_mode = LINE_MODE_APPID; + /* Update the appid here, same as the title. */ + free(private->appid); + private->appid = strdup(save_pointer); + break; } else if (strcmp(string, "fullscreen") == 0) line_mode = LINE_MODE_FULLSCREEN; else if (strcmp(string, "floating") == 0) @@ -235,6 +245,7 @@ process_line(char *line, struct module *module) } else switch (line_mode) { case LINE_MODE_TITLE: + case LINE_MODE_APPID: assert(false); /* unreachable */ break; case LINE_MODE_FULLSCREEN: