diff options
author | uint23 <[email protected]> | 2025-04-29 19:44:02 +0100 |
---|---|---|
committer | uint23 <[email protected]> | 2025-04-29 19:44:02 +0100 |
commit | 5eb226d371222ae219756e489f1e988ae06cd4ef (patch) | |
tree | 585af9013534391dc6c691d7a9d2f7c7bab87eea | |
parent | 821b0a17f8fa5b94d5c330469cdf08288d76f9b5 (diff) |
removed dependacy on config.h, updated readme to have config guide, updated default_sxrc
-rw-r--r-- | README.md | 79 | ||||
-rw-r--r-- | default_sxrc (renamed from defsxrc) | 25 | ||||
-rw-r--r-- | src/config.h | 70 | ||||
-rw-r--r-- | src/sxwm.c | 10 |
4 files changed, 127 insertions, 57 deletions
@@ -49,11 +49,82 @@ --- -## Default Configuration +## Configuration (`~/.config/sxwmrc`) -All options are in `sxwmrc` (which uses a simple DSL). -Keybindings are easy to read and edit. -No recompiling, no C code, just edit and reload! +`sxwm` is configured via a simple text file located at `~/.config/sxwmrc`. Changes can be applied instantly by reloading the configuration (default keybind: `MOD + r`). + +The file uses a `key : value` format. Lines starting with `#` are ignored. + +### General Options + +| Option | Type | Default | Description | +| ----------------------- | ------- | --------- | --------------------------------------------------------------------------- | +| `mod_key` | String | `super` | Sets the primary modifier key (`alt`, `super`, `ctrl`). | +| `gaps` | Integer | `10` | Pixels between windows and screen edges. | +| `border_width` | Integer | `1` | Thickness of window borders in pixels. | +| `focused_border_colour` | Hex | `#c0cbff` | Border color for the currently focused window. | +| `unfocused_border_colour`| Hex | `#555555` | Border color for unfocused windows. | +| `swap_border_colour` | Hex | `#fff4c0` | Border color highlight when selecting a window to swap with (`MOD+Shift+Drag`).| +| `master_width` | Integer | `60` | Percentage (%) of the screen width the master window should occupy. | +| `resize_master_amount` | Integer | `1` | Percentage (%) to increase/decrease the master width when resizing. | +| `snap_distance` | Integer | `5` | Pixels from screen edge before a floating window snaps to the edge. | +| `motion_throttle` | Integer | `60` | Target updates per second for mouse drag operations (move/resize/swap). Set close to your monitor's refresh rate for smoother visuals. | + +### Keybindings + +Keybindings associate key combinations with actions (either running external commands or internal `sxwm` functions). + +**Syntax:** + +``` sh +bind : [modifier + modifier + ... + key] : action +``` + +- **`bind`**: Keyword to define a keybinding. +- **`[...]`**: Contains the key combination. + - **Modifiers**: `mod` (uses the key set by `mod_key`), `shift`, `ctrl`, `alt`, `super`. Use `+` to combine multiple modifiers. + - **`key`**: The final key name (e.g., `Return`, `q`, `1`, `equal`, `space`). Key names generally follow X11 keysym names but are case-insensitive in the config. +- **`:`**: Separator. +- **`action`**: + - **Command**: An external command enclosed in double quotes (`"`). Arguments are separated by spaces (e.g., `"st -e vim"`). + - **Function**: The name of an internal `sxwm` function (see list below). + +**Available Functions:** + +| Function Name | Action | +| -------------------- | ----------------------------------------------------------- | +| `close_window` | Closes the currently focused window. | +| `decrease_gaps` | Decreases the gap size between windows. | +| `focus_next` | Shifts focus to the next window in the stack/list. | +| `focus_previous` | Shifts focus to the previous window in the stack/list. | +| `increase_gaps` | Increases the gap size between windows. | +| `master_next` | Moves the focused window down the master/stack order. | +| `master_previous` | Moves the focused window up the master/stack order. | +| `quit` | Exits `sxwm`. | +| `reload_config` | Reloads the `sxwmrc` configuration file. | +| `master_increase` | Increases the width allocated to the master area. | +| `master_decrease` | Decreases the width allocated to the master area. | +| `toggle_floating` | Toggles the floating state of the focused window. | +| `global_floating` | Toggles the floating state for *all* windows on the current workspace. | +| `fullscreen` | Toggles fullscreen mode for the focused window. | +| `change_ws[1-9]` | Switches focus to the specified workspace (1-9). | +| `moveto_ws[1-9]` | Moves the focused window to the specified workspace (1-9). | + +**Example Bindings:** + +```yaml +# Launch terminal with Mod + Enter +bind : [mod + Return] : "st" + +# Close focused window with Mod + Shift + Q +bind : [mod + shift + q] : close_window + +# Switch to workspace 3 with Mod + 3 +bind : [mod + 3] : change_ws3 + +# Move focused window to workspace 5 with Mod + Shift + 5 +bind : [mod + shift + 5] : moveto_ws5 +``` --- @@ -6,9 +6,10 @@ swap_border_colour : #fff4c0 # General Options: gaps : 10 border_width : 1 -master_coverage : 60 # Percentage of screen width +master_width : 60 # Percentage of screen width resize_master_amount : 1 snap_distance : 5 +motion_throttle : 60 # Set to screen refresh rate for smoothest motions # Keybinds: # Commands must be surrounded with "" @@ -16,40 +17,40 @@ snap_distance : 5 mod_key : super -# --- Application Launchers --- +# Application Launchers: bind : [mod + Return] : "st" bind : [mod + b] : "firefox" bind : [mod + p] : "dmenu_run" -# --- Window Management --- +# Window Management: bind : [mod + shift + q] : close_window bind : [mod + shift + e] : quit -# --- Focus Movement --- +# Focus Movement: bind : [mod + j] : focus_next bind : [mod + k] : focus_prev -# --- Master/Stack Movement --- -bind : [mod + shift + j] : move_master_next -bind : [mod + shift + k] : move_master_prev +# Master/Stack Movement +bind : [mod + shift + j] : master_next +bind : [mod + shift + k] : master_previous -# --- Master Area Resize --- +# Master Area Resize bind : [mod + l] : master_increase bind : [mod + h] : master_decrease -# --- Gaps --- +# Gaps bind : [mod + equal] : increase_gaps bind : [mod + minus] : decrease_gaps -# --- Floating/Fullscreen --- +# Floating/Fullscreen bind : [mod + space] : toggle_floating bind : [mod + shift + space] : global_floating bind : [mod + shift + f] : fullscreen -# --- Reload Config --- +# Reload Config bind : [mod + r] : reload_config -# --- Workspaces (1-9) --- +# Workspaces (1-9) bind : [mod + 1] : change_ws1 bind : [mod + shift + 1] : moveto_ws1 bind : [mod + 2] : change_ws2 diff --git a/src/config.h b/src/config.h index 0815b5b..64e664b 100644 --- a/src/config.h +++ b/src/config.h @@ -147,67 +147,65 @@ CMD(browser, "firefox"); */ /*< This is your modifier key (ALT/SUPER) >*/ -#define MOD SUPER - #include <X11/keysym.h> const Binding binds[] = { -/*————< MODIFIER(S) >< KEY >—————< FUNCTION >——*/ +/*————< Mod4MaskIFIER(S) >< KEY >—————< FUNCTION >——*/ /*———————< Here are your functions calls >————— — */ - CALL(MOD|SHIFT, e, quit), - CALL(MOD|SHIFT, q, close_focused), + CALL(Mod4Mask|SHIFT, e, quit), + CALL(Mod4Mask|SHIFT, q, close_focused), - CALL(MOD, j, focus_next), - CALL(MOD, k, focus_prev), + CALL(Mod4Mask, j, focus_next), + CALL(Mod4Mask, k, focus_prev), - CALL(MOD|SHIFT, j, move_master_next), - CALL(MOD|SHIFT, k, move_master_prev), + CALL(Mod4Mask|SHIFT, j, move_master_next), + CALL(Mod4Mask|SHIFT, k, move_master_prev), - CALL(MOD, l, resize_master_add), - CALL(MOD, h, resize_master_sub), + CALL(Mod4Mask, l, resize_master_add), + CALL(Mod4Mask, h, resize_master_sub), - CALL(MOD, equal, inc_gaps), - CALL(MOD, minus, dec_gaps), + CALL(Mod4Mask, equal, inc_gaps), + CALL(Mod4Mask, minus, dec_gaps), - CALL(MOD, space, toggle_floating), - CALL(MOD|SHIFT, space, toggle_floating_global), + CALL(Mod4Mask, space, toggle_floating), + CALL(Mod4Mask|SHIFT, space, toggle_floating_global), - CALL(MOD|SHIFT, f, toggle_fullscreen), + CALL(Mod4Mask|SHIFT, f, toggle_fullscreen), /*—————< Here are your executable functions >—————*/ - BIND(MOD, Return, terminal), - BIND(MOD, b, browser), + BIND(Mod4Mask, Return, terminal), + BIND(Mod4Mask, b, browser), /*—————< This is for workspaces >—————————————————*/ - CALL(MOD, 1, change_ws1), - CALL(MOD|SHIFT, 1, moveto_ws1), + CALL(Mod4Mask, 1, change_ws1), + CALL(Mod4Mask|SHIFT, 1, moveto_ws1), - CALL(MOD, 2, change_ws2), - CALL(MOD|SHIFT, 2, moveto_ws2), + CALL(Mod4Mask, 2, change_ws2), + CALL(Mod4Mask|SHIFT, 2, moveto_ws2), - CALL(MOD, 3, change_ws3), - CALL(MOD|SHIFT, 3, moveto_ws3), + CALL(Mod4Mask, 3, change_ws3), + CALL(Mod4Mask|SHIFT, 3, moveto_ws3), - CALL(MOD, 4, change_ws4), - CALL(MOD|SHIFT, 4, moveto_ws4), + CALL(Mod4Mask, 4, change_ws4), + CALL(Mod4Mask|SHIFT, 4, moveto_ws4), - CALL(MOD, 5, change_ws5), - CALL(MOD|SHIFT, 5, moveto_ws5), + CALL(Mod4Mask, 5, change_ws5), + CALL(Mod4Mask|SHIFT, 5, moveto_ws5), - CALL(MOD, 6, change_ws6), - CALL(MOD|SHIFT, 6, moveto_ws6), + CALL(Mod4Mask, 6, change_ws6), + CALL(Mod4Mask|SHIFT, 6, moveto_ws6), - CALL(MOD, 7, change_ws7), - CALL(MOD|SHIFT, 7, moveto_ws7), + CALL(Mod4Mask, 7, change_ws7), + CALL(Mod4Mask|SHIFT, 7, moveto_ws7), - CALL(MOD, 8, change_ws8), - CALL(MOD|SHIFT, 8, moveto_ws8), + CALL(Mod4Mask, 8, change_ws8), + CALL(Mod4Mask|SHIFT, 8, moveto_ws8), - CALL(MOD, 9, change_ws9), - CALL(MOD|SHIFT, 9, moveto_ws9), + CALL(Mod4Mask, 9, change_ws9), + CALL(Mod4Mask|SHIFT, 9, moveto_ws9), }; @@ -310,7 +310,7 @@ void hdl_button(XEvent *xev) } /* begin swap drag mode */ - if ((e->state & MOD) && (e->state & ShiftMask) && e->button == Button1 && !c->floating) { + if ((e->state & user_config.modkey) && (e->state & ShiftMask) && e->button == Button1 && !c->floating) { drag_client = c; drag_start_x = e->x_root; drag_start_y = e->y_root; @@ -328,7 +328,7 @@ void hdl_button(XEvent *xev) return; } - if ((e->state & MOD) && (e->button == Button1 || e->button == Button3) && !c->floating) { + if ((e->state & user_config.modkey) && (e->button == Button1 || e->button == Button3) && !c->floating) { focused = c; toggle_floating(); } @@ -1081,13 +1081,13 @@ void setup(void) StructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask | KeyPressMask | PropertyChangeMask); - XGrabButton(dpy, Button1, MOD, root, True, + XGrabButton(dpy, Button1, user_config.modkey, root, True, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None); - XGrabButton(dpy, Button1, MOD | ShiftMask, root, True, + XGrabButton(dpy, Button1, user_config.modkey | ShiftMask, root, True, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None); - XGrabButton(dpy, Button3, MOD, root, True, + XGrabButton(dpy, Button3, user_config.modkey, root, True, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None); XSync(dpy, False); |