diff --git a/README.md b/README.md
index 69aacd15..a6dd0114 100644
--- a/README.md
+++ b/README.md
@@ -40,6 +40,8 @@ libxml2, glib-2.0, cairo and pango.
- [ ] Implement client-menu
- [ ] Implement root-menu
+For further details see [wiki/Roadmap](https://github.com/johanmalm/labwc/wiki/Roadmap).
+
## Inspiration
Labwc has been inspired and inflenced by [openbox](https://github.com/danakj/openbox), [sway](https://github.com/swaywm/sway), [cage](https://www.hjdskes.nl/blog/cage-01/), [wio](https://wio-project.org/) and [rootston](https://github.com/swaywm/rootston)
@@ -67,5 +69,5 @@ Suggested apps:
To enable ASAN and UBSAN, run meson with `-Db_sanitize=address,undefined`
-For further details see [wiki/Build](https://github.com/labwc/wiki/Build).
+For further details see [wiki/Build](https://github.com/johanmalm/labwc/wiki/Build).
diff --git a/data/rc.xml b/data/rc.xml
index 19798ef9..e097bd6f 100644
--- a/data/rc.xml
+++ b/data/rc.xml
@@ -14,6 +14,15 @@
+
+ Clearlooks
+ NLIMC
+
+ sans
+ 8
+
+
+
diff --git a/include/rcxml.h b/include/rcxml.h
index 55f93884..1b0a099c 100644
--- a/include/rcxml.h
+++ b/include/rcxml.h
@@ -30,6 +30,7 @@ struct keybind *keybind_add(const char *keybind);
struct rcxml {
bool client_side_decorations;
+ char *theme_name;
struct wl_list keybinds;
};
diff --git a/src/config/rcxml.c b/src/config/rcxml.c
index 7196daf8..460e9a0c 100644
--- a/src/config/rcxml.c
+++ b/src/config/rcxml.c
@@ -78,8 +78,10 @@ static void entry(xmlNode *node, char *nodename, char *content)
fill_keybind(node, nodename, content);
if (!strcmp(nodename, "csd.lab"))
rc.client_side_decorations = get_bool(content);
- if (!strcmp(nodename, "layout.keyboard.lab"))
+ else if (!strcmp(nodename, "layout.keyboard.lab"))
setenv("XKB_DEFAULT_LAYOUT", content, 1);
+ else if (!strcmp(nodename, "name.theme"))
+ rc.theme_name = strdup(content);
}
static char *nodename(xmlNode *node, char *buf, int len)
diff --git a/src/theme/xbm/xbm.c b/src/theme/xbm/xbm.c
index 3df66047..5b90167a 100644
--- a/src/theme/xbm/xbm.c
+++ b/src/theme/xbm/xbm.c
@@ -6,9 +6,27 @@
#include
#include
+#include
#include "theme/xbm/xbm.h"
#include "theme/xbm/parse.h"
+#include "rcxml.h"
+
+struct dir {
+ const char *prefix;
+ const char *path;
+};
+
+static struct dir theme_dirs[] = {
+ { "XDG_DATA_HOME", "themes" },
+ { "HOME", ".local/share/themes" },
+ { "HOME", ".themes" },
+ { "XDG_DATA_HOME", "themes" },
+ { NULL, "/usr/share/themes" },
+ { NULL, "/usr/local/share/themes" },
+ { NULL, "opt/share/themes" },
+ { NULL, NULL }
+};
/* built-in 6x6 buttons */
char close_button_normal[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
@@ -16,12 +34,6 @@ char iconify_button_normal[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
char max_button_normal[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
char max_button_toggled[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
-/*
- * TODO: parse rc.xml theme name and look for icons properly.
- * Just using random icon to prove the point.
- */
-static char filename[] = "/usr/share/themes/Bear2/openbox-3/close.xbm";
-
static struct wlr_texture *texture_from_pixmap(struct wlr_renderer *renderer,
struct pixmap *pixmap)
{
@@ -42,11 +54,45 @@ static struct wlr_texture *builtin(struct wlr_renderer *renderer,
return texture;
}
+static char *theme_dir(void)
+{
+ static char buffer[4096] = { 0 };
+ if (buffer[0] != '\0')
+ return buffer;
+
+ struct stat st;
+ for (int i = 0; theme_dirs[i].path; i++) {
+ char *prefix = NULL;
+ struct dir d = theme_dirs[i];
+ if (d.prefix) {
+ prefix = getenv(d.prefix);
+ if (!prefix)
+ continue;
+ snprintf(buffer, sizeof(buffer), "%s/%s/%s/openbox-3",
+ prefix, d.path, rc.theme_name);
+ } else {
+ snprintf(buffer, sizeof(buffer), "%s/%s/openbox-3",
+ d.path, rc.theme_name);
+ }
+ if (!stat(buffer, &st) && S_ISDIR(st.st_mode))
+ return buffer;
+ }
+ buffer[0] = '\0';
+ return buffer;
+}
+
+static char *xbm_path(const char *button)
+{
+ static char buffer[4096] = { 0 };
+ snprintf(buffer, sizeof(buffer), "%s/%s", theme_dir(), button);
+ return buffer;
+}
+
void xbm_load(struct wlr_renderer *renderer)
{
struct token *tokens;
- char *buffer = xbm_read_file(filename);
+ char *buffer = xbm_read_file(xbm_path("close.xbm"));
if (!buffer) {
fprintf(stderr, "no buffer\n");
goto out;