Mercurial > gbwm
comparison gbwm.c @ 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 |
comparison
equal
deleted
inserted
replaced
2:3ad7c3ab949e | 3:3726f37deac1 |
---|---|
10 #include <string.h> | 10 #include <string.h> |
11 #include <unistd.h> | 11 #include <unistd.h> |
12 #include <signal.h> | 12 #include <signal.h> |
13 #include <sys/wait.h> | 13 #include <sys/wait.h> |
14 | 14 |
15 #define MOD Mod4Mask | |
16 #define GRID_ROWS 4 | |
17 #define GRID_COLS 7 | |
18 | |
19 // Grid 4 by 7 | |
20 static const char grid_chars[GRID_ROWS][GRID_COLS+1] = { | |
21 "1234567", | |
22 "qwertyu", | |
23 "asdfghj", | |
24 "zxcvbnm" | |
25 }; | |
26 | |
27 typedef struct Client Client; | 15 typedef struct Client Client; |
28 struct Client { | 16 struct Client { |
29 Window win; | 17 Window win; |
30 int x, y, w, h; | 18 int x, y, w, h; |
31 int saved_x, saved_y, saved_w, saved_h; // Saved position before fullscreen | 19 int saved_x, saved_y, saved_w, saved_h; // Saved position before fullscreen |
45 unsigned int mod; | 33 unsigned int mod; |
46 KeySym keysym; | 34 KeySym keysym; |
47 void (*func)(const Arg *); | 35 void (*func)(const Arg *); |
48 const Arg arg; | 36 const Arg arg; |
49 } Key; | 37 } Key; |
50 | |
51 // Configuration | |
52 static const int padding = 8; | |
53 static const int border_width = 2; | |
54 static const char *col_border_normal = "#444444"; | |
55 static const char *col_border_focused = "#4a90e2"; | |
56 static const char *col_bg = "#000000"; | |
57 static const char *col_fg = "#ffffff"; | |
58 static const char *col_sel = "#4a90e2"; | |
59 static const char *overlay_font = "monospace:size=48"; | |
60 | 38 |
61 static Display *dpy; | 39 static Display *dpy; |
62 static Window root; | 40 static Window root; |
63 static Client *workspaces[9] = {NULL}; // 9 workspaces | 41 static Client *workspaces[9] = {NULL}; // 9 workspaces |
64 static int current_ws = 0; | 42 static int current_ws = 0; |
95 static void updateborder(Client *c); | 73 static void updateborder(Client *c); |
96 static void find_next_free_cell(int *out_r, int *out_c); | 74 static void find_next_free_cell(int *out_r, int *out_c); |
97 static void switchws(const Arg *arg); | 75 static void switchws(const Arg *arg); |
98 static void movewin_to_ws(const Arg *arg); | 76 static void movewin_to_ws(const Arg *arg); |
99 | 77 |
100 // Commands | 78 #include "config.h" |
101 static const char *termcmd[] = { "alacritty", NULL }; | |
102 static const char *menucmd[] = { "dmenu_run", NULL }; | |
103 static const char *scrotcmd[] = { "scrot", NULL }; | |
104 | |
105 // Key bindings | |
106 static Key keys[] = { | |
107 /* modifier key function argument */ | |
108 { MOD, XK_t, enter_overlay, {0} }, | |
109 { MOD, XK_Return, spawn, {.v = termcmd} }, | |
110 { MOD, XK_p, spawn, {.v = menucmd} }, | |
111 { 0, XK_Print, spawn, {.v = scrotcmd} }, | |
112 { MOD, XK_q, killclient, {0} }, | |
113 { MOD, XK_f, toggle_fullscreen, {0} }, | |
114 { MOD, XK_Tab, cycle_focus, {0} }, | |
115 { MOD|ShiftMask, XK_q, quit, {0} }, | |
116 | |
117 // Workspaces | |
118 { MOD, XK_1, switchws, {.i = 0} }, | |
119 { MOD, XK_2, switchws, {.i = 1} }, | |
120 { MOD, XK_3, switchws, {.i = 2} }, | |
121 { MOD, XK_4, switchws, {.i = 3} }, | |
122 { MOD, XK_5, switchws, {.i = 4} }, | |
123 { MOD, XK_6, switchws, {.i = 5} }, | |
124 { MOD, XK_7, switchws, {.i = 6} }, | |
125 { MOD, XK_8, switchws, {.i = 7} }, | |
126 { MOD, XK_9, switchws, {.i = 8} }, | |
127 | |
128 // Move window to workspace | |
129 { MOD|ShiftMask, XK_1, movewin_to_ws, {.i = 0} }, | |
130 { MOD|ShiftMask, XK_2, movewin_to_ws, {.i = 1} }, | |
131 { MOD|ShiftMask, XK_3, movewin_to_ws, {.i = 2} }, | |
132 { MOD|ShiftMask, XK_4, movewin_to_ws, {.i = 3} }, | |
133 { MOD|ShiftMask, XK_5, movewin_to_ws, {.i = 4} }, | |
134 { MOD|ShiftMask, XK_6, movewin_to_ws, {.i = 5} }, | |
135 { MOD|ShiftMask, XK_7, movewin_to_ws, {.i = 6} }, | |
136 { MOD|ShiftMask, XK_8, movewin_to_ws, {.i = 7} }, | |
137 { MOD|ShiftMask, XK_9, movewin_to_ws, {.i = 8} }, | |
138 }; | |
139 | 79 |
140 // Event handlers | 80 // Event handlers |
141 static void buttonpress(XEvent *e) { | 81 static void buttonpress(XEvent *e) { |
142 for (Client *c = workspaces[current_ws]; c; c = c->next) | 82 for (Client *c = workspaces[current_ws]; c; c = c->next) |
143 if (c->win == e->xbutton.subwindow) { | 83 if (c->win == e->xbutton.subwindow) { |