summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Fadel <samuel@nihil.ws>2022-12-01 15:03:05 +0100
committerSamuel Fadel <samuel@nihil.ws>2022-12-01 15:03:05 +0100
commit7aa66702b2b9396add0cc20849ec89a48495c7ff (patch)
tree3d5bf019313264ff6527e5cfb464b060113b44aa
Initial commit.
Sketching Scheme/C interop.
-rw-r--r--.manifest.scm22
-rw-r--r--Makefile4
-rw-r--r--README.org20
-rw-r--r--main.scm4
-rw-r--r--schewm.c11
-rw-r--r--wm.scm24
6 files changed, 85 insertions, 0 deletions
diff --git a/.manifest.scm b/.manifest.scm
new file mode 100644
index 0000000..ef6bbf7
--- /dev/null
+++ b/.manifest.scm
@@ -0,0 +1,22 @@
+(use-modules (guix build-system gnu)
+ (guix download)
+ (guix packages)
+ ((guix licenses) :prefix license:)
+ (gnu packages base)
+ (gnu packages commencement)
+ (gnu packages cpp)
+ (gnu packages guile)
+ (gnu packages pkg-config)
+ (gnu packages xorg))
+
+
+(packages->manifest
+ (list
+ gnu-make
+ gcc-toolchain
+ pkg-config
+ libxcb
+ xcb-util-keysyms
+ xcb-util-wm
+ ccls
+ ))
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..3d127d2
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+all: libschewm.so
+
+libschewm.so: schewm.c
+ gcc -fPIC -Wall -shared -o libschewm.so schewm.c
diff --git a/README.org b/README.org
new file mode 100644
index 0000000..8ddf847
--- /dev/null
+++ b/README.org
@@ -0,0 +1,20 @@
+* Introduction
+
+`schewn' (pronounced skew with an extra `n' sound at the end) is a
+floating and manual tiling window manager written in C for performance
+and (Guile) Scheme for extensibility (and configuration).
+
+As expected from most window managers, every action is configurable to
+be bound to a set of keys or mouse actions. The internals of `schewn'
+are kept to its C core, but its capabilities are exposed as a Scheme
+API.
+
+This project aims to provide something more akin to `2bwm' but with
+Scheme extensibility, with the aim of being a more ergonomic, dynamic,
+and convenient way of configuring the window manager to do what the
+user wants without wondering about recompiling its source code.
+
+Compared to StumpWM, we do not aim to have a Lisp-based window
+manager, but rather a convenient library of Scheme functions which
+only expose the functionality of the window manager, while having a
+core in C which does the heavy lifting.
diff --git a/main.scm b/main.scm
new file mode 100644
index 0000000..07c2f04
--- /dev/null
+++ b/main.scm
@@ -0,0 +1,4 @@
+(use-modules (wm))
+
+(when (wm-init)
+ (wm-quit "hello"))
diff --git a/schewm.c b/schewm.c
new file mode 100644
index 0000000..72f89bf
--- /dev/null
+++ b/schewm.c
@@ -0,0 +1,11 @@
+#include <stdio.h>
+#include <stdbool.h>
+#include <stdlib.h>
+
+bool wm_init() {
+ return true;
+}
+
+void wm_quit(const char *m) {
+ printf("hello, %s\n", m);
+}
diff --git a/wm.scm b/wm.scm
new file mode 100644
index 0000000..8304dca
--- /dev/null
+++ b/wm.scm
@@ -0,0 +1,24 @@
+(define-module (wm)
+ #:use-module (system foreign)
+ #:export (wm-init wm-quit))
+
+(define libschewm (dynamic-link "libschewm"))
+
+(define (int-as-bool i)
+ (not (eq? 0 i)))
+
+(define (schewm-func return-type name args)
+ (pointer->procedure
+ return-type
+ (dynamic-func name libschewm)
+ args))
+
+(define (wm-init)
+ (let ((c/wm-init
+ (schewm-func int "wm_init" '())))
+ (int-as-bool (c/wm-init))))
+
+(define (wm-quit s)
+ (let ((c/wm-quit
+ (schewm-func void "wm_quit" (list '*))))
+ (c/wm-quit (string->pointer s))))