summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--src/sxwm.c46
-rw-r--r--src/sxwm.h6
-rw-r--r--src/user.config6
-rw-r--r--src/util.h4
-rw-r--r--src/utils.c30
6 files changed, 56 insertions, 38 deletions
diff --git a/Makefile b/Makefile
index 2cdfaf1..5280540 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,7 @@ $(BIN): $(OBJ)
$(SRC_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) -c -o $@ $<
-x:
+c:
rm -f $(SRC_DIR)/*.o $(BIN)
r:
diff --git a/src/sxwm.c b/src/sxwm.c
index 19b8975..9604d3e 100644
--- a/src/sxwm.c
+++ b/src/sxwm.c
@@ -1,5 +1,36 @@
+/* See LICENSE for more info
+
+ sxwm is a user-friendly, easily configurable yet powerful
+ tiling window manager inspired by window managers such as
+ DWM and i3
+
+ The userconfig is designed to be as user-friendly as
+ possible, and I hope it is easy to configure even without
+ knowledge of C or programming, although most people who
+ will use this will probably be programmers :)
+
+*/// (C) Abhinav Prasai 2025
+
#include "sxwm.h"
-#include "util.h"
+
+static void
+otherwm(void)
+{
+ XSetErrorHandler(otherwmerr);
+ XChangeWindowAttributes(dpy, root, CWEventMask,
+ &(XSetWindowAttributes){.event_mask = SubstructureRedirectMask});
+ XSync(dpy, False);
+ XSetErrorHandler(xerr);
+ XSync(dpy, False);
+}
+
+static int
+otherwmerr(Display *dpy, XErrorEvent *ee)
+{
+ errx(0, "sxwm: another window manager is already running, please close it");
+ return 0;
+ if (dpy && ee) return 0;
+}
static void
run(void)
@@ -10,7 +41,7 @@ run(void)
}
}
-void
+static void
setup(void)
{
dpy = XOpenDisplay(NULL);
@@ -24,6 +55,15 @@ setup(void)
);
}
+static int
+xerr(Display *dpy, XErrorEvent *ee)
+{
+ fprintf(stderr, "sxwm: fatal error\nrequest code:%d\nerror code:%d",
+ ee->request_code, ee->error_code);
+ return 0;
+ if (dpy && ee) return 0;
+}
+
int
main(int ac, char **av)
{
@@ -33,7 +73,7 @@ main(int ac, char **av)
else
errx(0, "usage:\n[-v || --version]: See the version of sxwm\n");
}
+ setup();
run();
- dpy = XOpenDisplay(NULL);
return 0;
}
diff --git a/src/sxwm.h b/src/sxwm.h
index cb6286c..f1ef7e5 100644
--- a/src/sxwm.h
+++ b/src/sxwm.h
@@ -1,10 +1,13 @@
#ifndef SXWM_H
#define SXWM_H
+#include <stdio.h>
#include <string.h>
#include <err.h>
#include <X11/Xlib.h>
+#include "user.config"
+
#define SXWM_VERSION "sxwm ver. 0.1.0"
#define SXWM_AUTHOR "(C) Abhinav Prasai 2025"
#define SXWM_LICINFO "See LICENSE for more info"
@@ -13,8 +16,11 @@
#define SUPER Mod4Mask
#define SHIFT ShiftMask
+static void otherwm(void);
+static int otherwmerr(Display *dpy, XErrorEvent *ee);
static void run(void);
static void setup(void);
+static int xerr(Display *dpy, XErrorEvent *ee);
static Display *dpy;
static Window root;
diff --git a/src/user.config b/src/user.config
new file mode 100644
index 0000000..f946501
--- /dev/null
+++ b/src/user.config
@@ -0,0 +1,6 @@
+#ifndef USER_CONFIG
+#define USER_CONFIG
+
+#define MODCONF Mod1Mask
+
+#endif
diff --git a/src/util.h b/src/util.h
index bc77105..70a5ce8 100644
--- a/src/util.h
+++ b/src/util.h
@@ -1,8 +1,4 @@
#ifndef UTIL_H
#define UTIL_H
-#include <X11/Xlib.h>
-
-void otherwm(void);
-int otherwmerr(Display *dpy, XErrorEvent *ee);
#endif
diff --git a/src/utils.c b/src/utils.c
index c99e74c..408a76a 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1,31 +1 @@
-#include <err.h>
-#include <X11/Xlib.h>
#include "util.h"
-
-void
-otherwm(void)
-{
- XSetErrorHandler(otherwmerr);
- XChangeWindowAttributes(dpy, root, CWEventMask,
- &(XSetWindowAttributes){.event_mask = SubstructureRedirectMask});
- XSync(dpy, False);
- XSetErrorHandler(xerr);
- XSync(dpy, False);
-}
-
-int
-otherwmerr(Display *dpy, XErrorEvent *ee)
-{
- errx(0, "sxwm: another window manager is already running, please close it");
- return 0;
- if (dpy && ee) return 0;
-}
-
-int
-xerr(Display *dpy, XErrorEvent *ee)
-{
- fprintf(stderr, "sxwm: fatal error\nrequest code:%d\nerror code:%d",
- ee->request_code, ee->error_code);
- return 0;
- if (dpy && ee) return 0;
-}