- [x] Support xwayland
- [x] Parse [rc.xml](data/rc.xml)
-- [x] Parse [themerc](data/themerc)
+- [x] Parse [themerc](data/themes/labwc-default/openbox-3/themerc)
- [x] Read xbm icons
- [x] Show maximize, minimize, close buttons
- [ ] Give actions to maximize, minimize, close buttons
## Configuration
-See [rc.xml](data/rc.xml) and [themerc](data/themerc) comments for details including keybinds.
+See [rc.xml](data/rc.xml) and [themerc](data/themes/labwc-default/openbox-3/themerc) comments for details including keybinds.
Suggest either copying data/rc.xml to ~/.config/labwc/running, or running with:
/*
- * Very simple C buffer implementation
+ * Very simple C string buffer implementation
*
* Copyright Johan Malm 2020
*/
-#ifndef BUF_H
-#define BUF_H
+#ifndef __LABWC_BUF_H
+#define __LABWC_BUF_H
#include <stdio.h>
#include <stdlib.h>
int len;
};
+/*
+ * buf_init - allocate NULL-terminated C string buffer
+ * @s - buffer
+ * Note: use free(s->buf) to free it.
+ */
void buf_init(struct buf *s);
+
+/*
+ * buf_add - add data to C string buffer
+ * @s - buffer
+ * @data - data to be added
+ */
void buf_add(struct buf *s, const char *data);
-#endif /* BUF_H */
+#endif /* __LABWC_BUF_H */
#ifndef __LABWC_BUG_ON_H
#define __LABWC_BUG_ON_H
+/*
+ * BUG_ON - assert() without abort()
+ * @condition - expression to be evaluated
+ */
#define BUG_ON(condition) \
do { \
if ((condition) != 0) { \
} \
} while (0)
-#endif /* __LABWC_BUT_ON_H */
-
+#endif /* __LABWC_BUG_ON_H */
--- /dev/null
+#ifndef __LABWC_SPAWN_H
+#define __LABWC_SPAWN_H
+
+/**
+ * spawn_async_no_shell - execute asyncronously
+ * @command: command to be executed
+ */
+void spawn_async_no_shell(char const *command);
+
+#endif /* __LABWC_SPAWN_H */
-#ifndef CONFIG_DIR_H
-#define CONFIG_DIR_H
+#ifndef __LABWC_CONFIG_DIR_H
+#define __LABWC_CONFIG_DIR_H
char *config_dir(void);
-#endif /* CONFIG_DIR_H */
+#endif /* __LABWC_CONFIG_DIR_H */
--- /dev/null
+#ifndef __LABWC_KEYBIND_H
+#define __LABWC_KEYBIND_H
+
+#include <wlr/types/wlr_keyboard.h>
+#include <xkbcommon/xkbcommon.h>
+
+struct keybind {
+ uint32_t modifiers;
+ xkb_keysym_t *keysyms;
+ size_t keysyms_len;
+ char *action;
+ char *command;
+ struct wl_list link;
+};
+
+struct keybind *keybind_add(const char *keybind);
+
+#endif /* __LABWC_KEYBIND_H */
-#ifndef RCXML_H
-#define RCXML_H
+#ifndef __LABWC_RCXML_H
+#define __LABWC_RCXML_H
#include <stdio.h>
#include <stdbool.h>
-#include <wlr/types/wlr_keyboard.h>
#include <wayland-server-core.h>
-#include <xkbcommon/xkbcommon.h>
#include "common/buf.h"
-struct keybind {
- uint32_t modifiers;
- xkb_keysym_t *keysyms;
- size_t keysyms_len;
- char *action;
- char *command;
- struct wl_list link;
-};
-
-struct keybind *keybind_add(const char *keybind);
-
struct rcxml {
bool client_side_decorations;
char *theme_name;
void rcxml_read(const char *filename);
void rcxml_get_nodenames(struct buf *b);
-#endif /* RCXML_H */
+#endif /* __LABWC_RCXML_H */
-#ifndef LABWC_H
-#define LABWC_H
+#ifndef __LABWC_H
+#define __LABWC_H
#define _POSIX_C_SOURCE 200809L
#include <getopt.h>
#include <wlr/xwayland.h>
#include <xkbcommon/xkbcommon.h>
-#include "rcxml.h"
+#include "config/rcxml.h"
+#include "config/keybind.h"
#define XCURSOR_DEFAULT "left_ptr"
#define XCURSOR_SIZE 24
void dbg_show_views(struct server *server);
void dbg_show_keybinds();
-#endif /* LABWC_H */
+#endif /* __LABWC_H */
+++ /dev/null
-#ifndef SPAWN_H
-#define SPAWN_H
-
-void spawn_async_no_shell(char const *command);
-
-#endif /* SPAWN_H */
-#ifndef THEME_DIR_H
-#define THEME_DIR_H
+#ifndef __LABWC_THEME_DIR_H
+#define __LABWC_THEME_DIR_H
char *theme_dir(const char *theme_name);
-#endif /* THEME_DIR_H */
+#endif /* __LABWC_THEME_DIR_H */
* Copyright Johan Malm 2020
*/
-#ifndef THEME_H
-#define THEME_H
+#ifndef __LABWC_THEME_H
+#define __LABWC_THEME_H
#include <stdio.h>
#include <wlr/render/wlr_renderer.h>
void theme_read(const char *theme_name);
-#endif /* THEME_H */
+#endif /* __LABWC_THEME_H */
* Copyright Johan Malm 2020
*/
-#ifndef PARSE_H
-#define PARSE_H
+#ifndef __LABWC_PARSE_H
+#define __LABWC_PARSE_H
#include <stdint.h>
#include "theme/xbm/tokenize.h"
struct pixmap xbm_create_pixmap_builtin(const char *button);
-#endif /* PARSE_H */
+#endif /* __LABWC_PARSE_H */
* Copyright Johan Malm 2020
*/
-#ifndef TOKENIZE_H
-#define TOKENIZE_H
+#ifndef __LABWC_TOKENIZE_H
+#define __LABWC_TOKENIZE_H
enum token_type {
TOKEN_NONE = 0,
*/
char *xbm_read_file(const char *filename);
-#endif /* TOKENIZE_H */
+#endif /* __LABWC_TOKENIZE_H */
-#ifndef XBM_H
-#define XBM_H
+#ifndef __LABWC_XBM_H
+#define __LABWC_XBM_H
#include <wlr/render/wlr_renderer.h>
-#include "theme.h"
#include "theme/xbm/parse.h"
/**
*/
void xbm_load(struct wlr_renderer *renderer);
-#endif /* XBM_H */
+#endif /* __LABWC_XBM_H */
#include "labwc.h"
-#include "spawn.h"
+#include "common/spawn.h"
#include <strings.h>
return;
}
g_spawn_async(NULL, argv, NULL,
- G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
- NULL, NULL, NULL, &err);
+ G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL,
+ NULL, NULL, &err);
if (err) {
g_message("%s", err->message);
g_error_free(err);
#include <string.h>
#include <glib.h>
-#include "rcxml.h"
+#include "config/keybind.h"
+#include "config/rcxml.h"
static uint32_t parse_modifier(const char *symname)
{
memcpy(k->keysyms, keysyms, k->keysyms_len * sizeof(xkb_keysym_t));
return k;
}
-
#include <fcntl.h>
#include <wayland-server-core.h>
-#include "rcxml.h"
+#include "config/rcxml.h"
+#include "config/keybind.h"
#include "config/config-dir.h"
#include "common/bug-on.h"
#include "labwc.h"
-#include "rcxml.h"
+#include "config/rcxml.h"
+#include "config/keybind.h"
static void show_one_xdg_view(struct view *view)
{
*/
#include "labwc.h"
-#include "theme.h"
+#include "theme/theme.h"
/* Based on expected font height of Sans 8 */
#define TITLE_HEIGHT (14)
#include "labwc.h"
-#include "theme.h"
-#include "spawn.h"
+#include "theme/theme.h"
#include "theme/xbm/xbm.h"
+#include "common/spawn.h"
struct server server = { 0 };
struct rcxml rc = { 0 };
#include "labwc.h"
-#include "theme.h"
+#include "theme/theme.h"
struct draw_data {
struct wlr_renderer *renderer;
prefix = getenv(d.prefix);
if (!prefix)
continue;
- snprintf(buf, sizeof(buf), "%s/%s/%s/openbox-3",
- prefix, d.path, theme_name);
+ snprintf(buf, sizeof(buf), "%s/%s/%s/openbox-3", prefix,
+ d.path, theme_name);
} else {
snprintf(buf, sizeof(buf), "%s/%s/openbox-3", d.path,
theme_name);
#include <stdbool.h>
#include <glib.h>
-#include "theme.h"
+#include "theme/theme.h"
#include "theme/theme-dir.h"
static int hex_to_dec(char c)
#include <stdio.h>
#include <stdlib.h>
+#include "theme/theme.h"
#include "theme/xbm/xbm.h"
#include "theme/xbm/parse.h"
#include "theme/theme-dir.h"
-#include "rcxml.h"
+#include "config/rcxml.h"
/* built-in 6x6 buttons */
char close_button_normal[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
}
static struct wlr_texture *texture_from_builtin(struct wlr_renderer *renderer,
- const char *button)
+ const char *button)
{
struct pixmap pixmap = xbm_create_pixmap_builtin(button);
struct wlr_texture *texture = texture_from_pixmap(renderer, &pixmap);
{
load_button(r, "close.xbm", &theme.xbm_close, close_button_normal);
load_button(r, "max.xbm", &theme.xbm_maximize, max_button_normal);
- load_button(r, "iconify.xbm", &theme.xbm_iconify, iconify_button_normal);
+ load_button(r, "iconify.xbm", &theme.xbm_iconify,
+ iconify_button_normal);
}
#include <unistd.h>
#include <stdbool.h>
-#include "rcxml.h"
+#include "config/rcxml.h"
#include "tap.h"
struct rcxml rc = { 0 };
#include <stdbool.h>
#include <string.h>
-#include "rcxml.h"
+#include "config/rcxml.h"
#include "tap.h"
struct rcxml rc = { 0 };
hex-color-average: hex-color-average.o
clean:
- rm -f hex-color-average
+ rm -f hex-color-average *.o
#include <stdlib.h>
#include <unistd.h>
-#include "rcxml.h"
+#include "config/rcxml.h"
#include "common/buf.h"
struct rcxml rc = { 0 };
CFLAGS = -g -Wall -Wextra -pedantic -std=c11
CFLAGS += -I../../include/
+CFLAGS += `pkg-config --cflags glib-2.0`
ASAN_FLAGS = -O0 -fsanitize=address -fno-common -fno-omit-frame-pointer -rdynamic
CFLAGS += $(ASAN_FLAGS)
LDFLAGS += $(ASAN_FLAGS) -fuse-ld=gold
+LDFLAGS += `pkg-config --cflags --libs glib-2.0 wlroots wayland-server`
+LDFLAGS += -DWLR_USE_UNSTABLE
+
+SRCS = \
+ theme-helper.c \
+ ../../src/theme/theme.c \
+ ../../src/theme/theme-dir.c
all:
- gcc $(CFLAGS) -o theme-helper theme-helper.c ../../src/theme/theme.c $(LDFLAGS)
+ gcc $(CFLAGS) -o theme-helper $(SRCS) $(LDFLAGS)
+
+
+test:
+ XDG_DATA_HOME=../../data ./theme-helper labwc-default
+
+clean:
+ rm -f theme-helper *.o
#include <stdio.h>
#include <stdlib.h>
-#include "../../include/theme.h"
+#include "theme/theme.h"
struct theme theme = { 0 };
-int main()
+static void usage(const char *application)
{
- theme_read("../../data/themerc");
+ printf("Usage: %s <theme-name>\n", application);
+ exit(1);
+}
+
+int main(int argc, char **argv)
+{
+ if (argc < 2)
+ usage(argv[0]);
+ theme_read(argv[1]);
+
+ printf("window_active_title_bg_color = ");
for (int i=0; i < 4; i++)
printf("%.2f; ", theme.window_active_title_bg_color[i]);
printf("\n");