aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2021-09-29 10:54:50 -0700
committerNicholas Noll <nbnoll@eml.cc>2021-09-29 10:54:50 -0700
commitd20be3112770c9fd252c91306675717dcb59e28f (patch)
tree91e41d2ff8e9bb82363eb0faeace9218263beede
parent88b8c199e3524b7c4e2667db3683c77d70f34a26 (diff)
chore(wm): add forgotten files
-rw-r--r--sys/cmd/wm/arg.c21
-rw-r--r--sys/cmd/wm/config.h29
-rw-r--r--sys/cmd/wm/util.c10
3 files changed, 60 insertions, 0 deletions
diff --git a/sys/cmd/wm/arg.c b/sys/cmd/wm/arg.c
new file mode 100644
index 0000000..bf58534
--- /dev/null
+++ b/sys/cmd/wm/arg.c
@@ -0,0 +1,21 @@
+#include "wm.h"
+
+void
+spawn(Arg *arg)
+{
+ if(!fork()) {
+ dup2(2, 1);
+ setsid();
+ execvp(((char **)arg->v)[0], (char **)arg->v);
+ }
+}
+
+void
+quit(Arg *arg)
+{
+ wl_display_terminate(server.display);
+}
+
+#define CONFIG(a,b,...) a cfg·##b = __VA_ARGS__
+#include "config.h"
+#undef CONFIG
diff --git a/sys/cmd/wm/config.h b/sys/cmd/wm/config.h
new file mode 100644
index 0000000..dbeeaf6
--- /dev/null
+++ b/sys/cmd/wm/config.h
@@ -0,0 +1,29 @@
+/* appearance */
+CONFIG(int, sloppyfocus, 1);
+CONFIG(int, borderpixel, 1);
+CONFIG(float, rootcolor[], {0.3, 0.3, 0.3, 1.0});
+CONFIG(float, bordercolor[], {0.5, 0.5, 0.5, 1.0});
+CONFIG(float, focuscolor[], {1.0, 0.0, 0.0, 1.0});
+
+/* sampling */
+CONFIG(int, repeat_rate, 25);
+CONFIG(int, repeat_delay, 600);
+
+/* commands */
+CONFIG(char*, termcommand[], { "alacritty", nil });
+
+/* keybindings */
+#define MOD(a) WLR_MODIFIER_##a
+#define MODKEY WLR_MODIFIER_ALT
+#define KEY(a) XKB_KEY_##a
+
+CONFIG(Key, binding[], {
+ /* modifier key function argument */
+ { MODKEY, KEY(Return), spawn, {.v = cfg·termcommand} },
+ { MODKEY|MOD(SHIFT), KEY(Q), quit, {.v = nil} },
+});
+CONFIG(Key*, endbinding, arrend(cfg·binding));
+
+#undef MOD
+#undef MODKEY
+#undef KEY
diff --git a/sys/cmd/wm/util.c b/sys/cmd/wm/util.c
new file mode 100644
index 0000000..28b0e54
--- /dev/null
+++ b/sys/cmd/wm/util.c
@@ -0,0 +1,10 @@
+#include "wm.h"
+
+void
+scale_box(struct wlr_box *box, float scale)
+{
+ box->width = ROUND((box->x + box->width) * scale) - ROUND(box->x * scale);
+ box->height = ROUND((box->y + box->height) * scale) - ROUND(box->y * scale);
+ box->x = ROUND(box->x * scale);
+ box->y = ROUND(box->y * scale);
+}