changeset 3:3726f37deac1

Move config out of the main file
author Atarwn Gard <a@qwa.su>
date Sun, 12 Oct 2025 20:54:34 +0500
parents 3ad7c3ab949e
children f1f332156693
files Makefile default.config.h gbwm.c
diffstat 3 files changed, 75 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Sat Oct 11 10:15:35 2025 +0500
+++ b/Makefile	Sun Oct 12 20:54:34 2025 +0500
@@ -6,6 +6,9 @@
 $(TARGET):
 	$(CC) $(CFLAGS) gbwm.c -o $@ -lX11 -lXft -I/usr/include/freetype2/
 
+config.h: default.config.h
+	cp default.config.h config.h
+
 .PHONY: install uninstall clean
 
 install: $(TARGET)
@@ -15,4 +18,4 @@
 	rm -f $(DESTDIR)$(PREFIX)/bin/$(TARGET)
 
 clean:
-	rm -f $(TARGET)
\ No newline at end of file
+	rm -f $(TARGET)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/default.config.h	Sun Oct 12 20:54:34 2025 +0500
@@ -0,0 +1,70 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#include <X11/Xlib.h>
+#include <X11/keysym.h>
+
+// Modifier
+#define MOD Mod4Mask
+
+// Grid layout
+#define GRID_ROWS 4
+#define GRID_COLS 7
+static const char grid_chars[GRID_ROWS][GRID_COLS+1] = {
+    "1234567",
+    "qwertyu",
+    "asdfghj",
+    "zxcvbnm"
+};
+
+// Configuration
+static const int padding = 8;
+static const int border_width = 2;
+static const char *col_border_normal = "#444444";
+static const char *col_border_focused = "#4a90e2";
+static const char *col_bg = "#000000";
+static const char *col_fg = "#ffffff";
+static const char *col_sel = "#4a90e2";
+static const char *overlay_font = "LiberationMono:size=48";
+
+// Commands
+static const char *termcmd[] = { "st", NULL };
+static const char *menucmd[] = { "dmenu_run", NULL };
+static const char *scrotcmd[] = { "scrot", NULL };
+
+// Key bindings
+static Key keys[] = {
+    /* modifier         key              function         argument */
+    { MOD,              XK_a,            enter_overlay,   {0} },
+    { MOD,              XK_Return,       spawn,           {.v = termcmd} },
+    { MOD,              XK_p,            spawn,           {.v = menucmd} },
+    { 0,                XK_Print,        spawn,           {.v = scrotcmd} },
+    { MOD,              XK_q,            killclient,      {0} },
+    { MOD,              XK_f,            toggle_fullscreen, {0} },
+    { MOD,              XK_Tab,          cycle_focus,     {0} },
+    { MOD|ShiftMask,    XK_q,            quit,            {0} },
+    
+    // Workspaces
+    { MOD,              XK_1,            switchws,        {.i = 0} },
+    { MOD,              XK_2,            switchws,        {.i = 1} },
+    { MOD,              XK_3,            switchws,        {.i = 2} },
+    { MOD,              XK_4,            switchws,        {.i = 3} },
+    { MOD,              XK_5,            switchws,        {.i = 4} },
+    { MOD,              XK_6,            switchws,        {.i = 5} },
+    { MOD,              XK_7,            switchws,        {.i = 6} },
+    { MOD,              XK_8,            switchws,        {.i = 7} },
+    { MOD,              XK_9,            switchws,        {.i = 8} },
+    
+    // Move window to workspace
+    { MOD|ShiftMask,    XK_1,            movewin_to_ws,   {.i = 0} },
+    { MOD|ShiftMask,    XK_2,            movewin_to_ws,   {.i = 1} },
+    { MOD|ShiftMask,    XK_3,            movewin_to_ws,   {.i = 2} },
+    { MOD|ShiftMask,    XK_4,            movewin_to_ws,   {.i = 3} },
+    { MOD|ShiftMask,    XK_5,            movewin_to_ws,   {.i = 4} },
+    { MOD|ShiftMask,    XK_6,            movewin_to_ws,   {.i = 5} },
+    { MOD|ShiftMask,    XK_7,            movewin_to_ws,   {.i = 6} },
+    { MOD|ShiftMask,    XK_8,            movewin_to_ws,   {.i = 7} },
+    { MOD|ShiftMask,    XK_9,            movewin_to_ws,   {.i = 8} },
+};
+
+#endif /* CONFIG_H */
--- a/gbwm.c	Sat Oct 11 10:15:35 2025 +0500
+++ b/gbwm.c	Sun Oct 12 20:54:34 2025 +0500
@@ -12,18 +12,6 @@
 #include <signal.h>
 #include <sys/wait.h>
 
-#define MOD Mod4Mask
-#define GRID_ROWS 4
-#define GRID_COLS 7
-
-// Grid 4 by 7
-static const char grid_chars[GRID_ROWS][GRID_COLS+1] = {
-    "1234567",
-    "qwertyu",
-    "asdfghj",
-    "zxcvbnm"
-};
-
 typedef struct Client Client;
 struct Client {
     Window win;
@@ -48,16 +36,6 @@
     const Arg arg;
 } Key;
 
-// Configuration
-static const int padding = 8;
-static const int border_width = 2;
-static const char *col_border_normal = "#444444";
-static const char *col_border_focused = "#4a90e2";
-static const char *col_bg = "#000000";
-static const char *col_fg = "#ffffff";
-static const char *col_sel = "#4a90e2";
-static const char *overlay_font = "monospace:size=48";
-
 static Display *dpy;
 static Window root;
 static Client *workspaces[9] = {NULL};  // 9 workspaces
@@ -97,45 +75,7 @@
 static void switchws(const Arg *arg);
 static void movewin_to_ws(const Arg *arg);
 
-// Commands
-static const char *termcmd[] = { "alacritty", NULL };
-static const char *menucmd[] = { "dmenu_run", NULL };
-static const char *scrotcmd[] = { "scrot", NULL };
-
-// Key bindings
-static Key keys[] = {
-    /* modifier         key              function         argument */
-    { MOD,              XK_t,            enter_overlay,   {0} },
-    { MOD,              XK_Return,       spawn,           {.v = termcmd} },
-    { MOD,              XK_p,            spawn,           {.v = menucmd} },
-    { 0,                XK_Print,        spawn,           {.v = scrotcmd} },
-    { MOD,              XK_q,            killclient,      {0} },
-    { MOD,              XK_f,            toggle_fullscreen, {0} },
-    { MOD,              XK_Tab,          cycle_focus,     {0} },
-    { MOD|ShiftMask,    XK_q,            quit,            {0} },
-    
-    // Workspaces
-    { MOD,              XK_1,            switchws,        {.i = 0} },
-    { MOD,              XK_2,            switchws,        {.i = 1} },
-    { MOD,              XK_3,            switchws,        {.i = 2} },
-    { MOD,              XK_4,            switchws,        {.i = 3} },
-    { MOD,              XK_5,            switchws,        {.i = 4} },
-    { MOD,              XK_6,            switchws,        {.i = 5} },
-    { MOD,              XK_7,            switchws,        {.i = 6} },
-    { MOD,              XK_8,            switchws,        {.i = 7} },
-    { MOD,              XK_9,            switchws,        {.i = 8} },
-    
-    // Move window to workspace
-    { MOD|ShiftMask,    XK_1,            movewin_to_ws,   {.i = 0} },
-    { MOD|ShiftMask,    XK_2,            movewin_to_ws,   {.i = 1} },
-    { MOD|ShiftMask,    XK_3,            movewin_to_ws,   {.i = 2} },
-    { MOD|ShiftMask,    XK_4,            movewin_to_ws,   {.i = 3} },
-    { MOD|ShiftMask,    XK_5,            movewin_to_ws,   {.i = 4} },
-    { MOD|ShiftMask,    XK_6,            movewin_to_ws,   {.i = 5} },
-    { MOD|ShiftMask,    XK_7,            movewin_to_ws,   {.i = 6} },
-    { MOD|ShiftMask,    XK_8,            movewin_to_ws,   {.i = 7} },
-    { MOD|ShiftMask,    XK_9,            movewin_to_ws,   {.i = 8} },
-};
+#include "config.h"
 
 // Event handlers
 static void buttonpress(XEvent *e) {