1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
|
# SRDWM - Cross-Platform Window Manager
SRDWM is a modern, cross-platform window manager that provides a unified window management experience across Linux (X11/Wayland), Windows, and macOS. It features smart window placement, togglable decorations, and easy switching between tiling and floating layouts.
## Features
### **Cross-Platform Support**
- **Linux X11**: Full server-side decoration control with frame windows
- **Linux Wayland**: Modern wlroots compositor with zxdg-decoration protocol
- **Windows**: Native DWM border integration with global hooks
- **macOS**: Platform-constrained but functional with overlay windows
### **Smart Window Placement**
- **Windows 11-style grid placement** with optimal cell sizing
- **Cascade placement** for overlapping windows
- **Snap-to-edge** functionality
- **Overlap detection** and free space finding algorithms
### **Window Management**
- **Togglable decorations** with custom border colors and widths
- **Easy tiling/floating toggle** with per-window state management
- **Multiple layout engines**: Tiling, Dynamic, and Floating modes
- **Smart placement integration** for floating windows
### **Lua Configuration**
- **Scriptable configuration** with full Lua API
- **Real-time configuration reloading**
- **Platform-specific keybindings** and settings
- **Theme and decoration customization**
## Requirements
### **Linux (X11)**
```bash
# Ubuntu/Debian
sudo apt install build-essential cmake pkg-config liblua5.4-dev \
libx11-dev libxrandr-dev libxinerama-dev libxcb-dev \
libxcb-keysyms1-dev libxcb-icccm4-dev
# Fedora
sudo dnf install gcc-c++ cmake pkgconfig lua-devel \
libX11-devel libXrandr-devel libXinerama-devel libxcb-devel \
libxcb-keysyms-devel libxcb-icccm-devel
# Arch Linux
sudo pacman -S base-devel cmake pkgconf lua \
libx11 libxrandr libxinerama libxcb \
xcb-util xcb-util-keysyms xcb-util-wm
```
### **Linux (Wayland)**
```bash
# Ubuntu/Debian
sudo apt install build-essential cmake pkg-config liblua5.4-dev \
libwayland-dev wayland-protocols libwlroots-dev
# Fedora
sudo dnf install gcc-c++ cmake pkgconfig lua-devel \
wayland-devel wayland-protocols-devel wlroots-devel
# Arch Linux
sudo pacman -S base-devel cmake pkgconf lua \
wayland wayland-protocols wlroots
```
### **Windows**
- Visual Studio 2019 or later with C++17 support
- CMake 3.16 or later
- Lua 5.4 or later
### **macOS**
```bash
# Install dependencies via Homebrew
brew install cmake lua pkg-config
# Install Xcode Command Line Tools
xcode-select --install
```
## Installation
### **Quick Start (Linux/macOS)**
```bash
# Clone and bootstrap (deps + build + test + install)
git clone https://github.com/srdusr/srdwm.git
cd srdwm
bash scripts/bootstrap.sh --all
# X11-only build
# bash scripts/bootstrap.sh --all --no-wayland
# Real Wayland backend (requires wlroots deps)
# bash scripts/bootstrap.sh --all --real-wayland
```
### **Building from Source**
1. **Clone the repository**
```bash
git clone https://github.com/srdusr/srdwm.git
cd srdwm
```
2. **Create build directory**
```bash
mkdir build
cd build
```
3. **Configure and build**
```bash
cmake -S . -B build
cmake --build build -j$(nproc)
```
4. **Install**
```bash
sudo cmake --install build --prefix /usr/local
```
### **Platform-Specific Installation**
#### **Linux**
```bash
# Install to system
sudo cmake --install build --prefix /usr/local
# Or install to user directory
make install DESTDIR=$HOME/.local
```
#### **Windows**
```cmd
# Build with Visual Studio
cmake -G "Visual Studio 16 2019" -A x64 ..
cmake --build . --config Release
# Install
cmake --install . --prefix "C:\Program Files\SRDWM"
```
#### **macOS**
```bash
# Build and install
make -j$(sysctl -n hw.ncpu)
sudo make install
```
## Configuration
### **Basic Configuration**
Create your configuration file at `~/.config/srdwm/init.lua`:
```lua
-- Basic SRDWM configuration
print("Loading SRDWM configuration...")
-- Global settings
srd.set("general.decorations_enabled", true)
srd.set("general.border_width", 3)
srd.set("general.border_color", "#2e3440")
-- Layout settings
srd.set("general.default_layout", "dynamic")
srd.set("general.smart_placement", true)
-- Keybindings
srd.bind("Mod4+Return", function()
-- Open terminal
srd.spawn("alacritty")
end)
srd.bind("Mod4+q", function()
-- Close focused window
srd.window.close()
end)
srd.bind("Mod4+f", function()
-- Toggle floating
local window = srd.window.focused()
if window then
srd.window.toggle_floating(window.id)
end
end)
-- Layout switching
srd.bind("Mod4+1", function() srd.layout.set("tiling") end)
srd.bind("Mod4+2", function() srd.layout.set("dynamic") end)
srd.bind("Mod4+3", function() srd.layout.set("floating") end)
print("Configuration loaded successfully!")
```
### **Platform-Specific Configuration**
#### **Linux X11**
```lua
-- X11-specific settings
if srd.get_platform() == "x11" then
srd.set("general.border_width", 3)
srd.set("general.decorations_enabled", true)
-- X11-specific keybindings
srd.bind("Mod4+x", function()
local window = srd.window.focused()
if window then
srd.window.set_decorations(window.id, not srd.window.get_decorations(window.id))
end
end)
end
```
#### **Linux Wayland**
```lua
-- Wayland-specific settings
if srd.get_platform() == "wayland" then
srd.set("general.border_width", 2)
srd.set("general.decorations_enabled", true)
-- Wayland-specific keybindings
srd.bind("Mod4+w", function()
local window = srd.window.focused()
if window then
srd.window.set_decorations(window.id, not srd.window.get_decorations(window.id))
end
end)
end
```
#### **Windows**
```lua
-- Windows-specific settings
if srd.get_platform() == "windows" then
srd.set("general.border_width", 2)
srd.set("general.decorations_enabled", true)
-- Windows-specific keybindings
srd.bind("Mod4+d", function()
local window = srd.window.focused()
if window then
srd.window.set_border_color(window.id, 255, 0, 0) -- Red border
end
end)
end
```
#### **macOS**
```lua
-- macOS-specific settings
if srd.get_platform() == "macos" then
srd.set("general.border_width", 1)
srd.set("general.decorations_enabled", false) -- Limited support
-- macOS-specific keybindings
srd.bind("Mod4+m", function()
print("macOS: Overlay window toggle requested")
end)
end
```
## Usage
### **Starting SRDWM**
#### **Linux**
```bash
# X11
srdwm --platform x11
# Wayland
srdwm --platform wayland
```
#### **Windows**
```cmd
# Start from command line
srdwm.exe
# Or add to startup
```
#### **macOS**
```bash
# Start from command line
srdwm
# Or add to login items
```
### **Keybindings**
| Key | Action |
|-----|--------|
| `Mod4+Return` | Open terminal |
| `Mod4+q` | Close focused window |
| `Mod4+f` | Toggle floating |
| `Mod4+1/2/3` | Switch layouts (tiling/dynamic/floating) |
| `Mod4+b/n/r` | Change border colors (green/blue/red) |
| `Mod4+0` | Reset decorations |
| `Mod4+s` | Smart placement info |
### **Layouts**
- **Tiling**: Traditional tiling layout
- **Dynamic**: Smart placement with Windows 11-style algorithms
- **Floating**: Free-form window placement
## Testing
### **Running Tests**
```bash
# Build tests
cd build
make
# Run all tests
ctest
# Run specific tests
./tests/test_smart_placement
./tests/test_platform_factory
./tests/test_lua_manager
```
### **Platform-Specific Tests**
```bash
# Linux X11
./tests/test_x11_platform
# Linux Wayland
./tests/test_wayland_platform
# Windows
./tests/test_windows_platform
# macOS
./tests/test_macos_platform
```
### **One-command dependency installers**
```bash
# Ubuntu/Debian
bash scripts/install_deps_ubuntu.sh
# Fedora
bash scripts/install_deps_fedora.sh
# Arch Linux
bash scripts/install_deps_arch.sh
# openSUSE
bash scripts/install_deps_opensuse.sh
# Alpine Linux
bash scripts/install_deps_alpine.sh
# macOS (Homebrew)
bash scripts/install_deps_macos.sh
```
For full package lists per platform see `DEPENDENCIES.md`.
Wayland is enabled by default with a stub backend for compatibility. Switch to the real wlroots backend with `-DUSE_WAYLAND_STUB=OFF` (or `--real-wayland` in `scripts/bootstrap.sh`) once dependencies are installed.
## Documentation
- [API Documentation](docs/api.md)
- [Configuration Guide](docs/configuration.md)
- [Platform Implementation](docs/platforms.md)
- [Contributing Guide](CONTRIBUTING.md)
## Installed binary and desktop sessions
- The installed binary is named `srdwm` (a compatibility symlink `SRDWM` is also created in the same directory).
- Desktop session files are installed so you can pick SRDWM at login:
- X11 session: `/usr/local/share/xsessions/srdwm.desktop`
- Wayland session: `/usr/local/share/wayland-sessions/srdwm-wayland.desktop`
- If your display manager (GDM/SDDM/LightDM) doesn’t show them, ensure it reads sessions from `/usr/local/share/*sessions` or adjust your install prefix.
Install options (CMake variables):
- `-DSRDWM_INSTALL_X11_SESSION=ON|OFF` — install X11 session file (default ON)
- `-DSRDWM_INSTALL_WAYLAND_SESSION=ON|OFF` — install Wayland session file (default ON)
Example:
```bash
cmake -S . -B build -DSRDWM_INSTALL_WAYLAND_SESSION=OFF
cmake --build build -j
sudo cmake --install build --prefix /usr/local
```
## Using SRDWM from another CMake project
After installing SRDWM (e.g., `sudo cmake --install build --prefix /usr/local` on Linux/macOS), you can consume it in another CMake project via `find_package` and link to the exported target.
Minimal example `CMakeLists.txt`:
```cmake
cmake_minimum_required(VERSION 3.20)
project(MyApp LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(SRDWM REQUIRED) # provides SRDWM::SRDWM and pulls Lua automatically
add_executable(my_app main.cc)
target_link_libraries(my_app PRIVATE SRDWM::SRDWM)
```
Notes:
- On Linux/macOS, ensure the install prefix (default `/usr/local`) is in CMake’s package search path. You can hint it via `-DCMAKE_PREFIX_PATH=/usr/local` if needed.
- On Windows with vcpkg, pass your toolchain file when configuring your consumer project:
```powershell
cmake -S . -B build -G Ninja -DCMAKE_TOOLCHAIN_FILE="C:/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake"
```
- The exported package config internally requires Lua (handled by the SRDWM package config).
## Contributing
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.
### **Development Setup**
```bash
# Clone with submodules
git clone --recursive https://github.com/srdusr/srdwm.git
cd srdwm
# Install development dependencies
sudo apt install build-essential cmake pkg-config liblua5.3-dev \
libx11-dev libxrandr-dev libxinerama-dev libxcb-dev \
libxcb-keysyms1-dev libxcb-icccm4-dev libwayland-dev \
wayland-protocols libwlroots-dev libgtest-dev
# Build with tests
mkdir build && cd build
cmake -DBUILD_TESTS=ON ..
make -j$(nproc)
# Run tests
ctest
```
## Acknowledgments
- **Hyprland** for Wayland compositor inspiration
- **DWM** for X11 window management concepts
- **i3** for tiling layout ideas
- **Windows 11** for smart placement algorithms
## Support
- **Issues**: [GitHub Issues](https://github.com/srdusr/srdwm/issues)
- **Discussions**: [GitHub Discussions](https://github.com/srdusr/srdwm/discussions)
- **Wiki**: [GitHub Wiki](https://github.com/srdusr/srdwm/wiki)
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|