tony / oxwm

Branch: b33b7bb
Switch branches/tags
master
tonybanters fixed bug where window was not snapping to the right on scroll mode, and also added toggle-able indicator for scroll mode in bar. 9ae47bd 2026-09-22
387 lines · 16.3 KB Raw Blame History
1 ---@meta
2 -------------------------------------------------------------------------------
3 -- OXWM Configuration File
4 -------------------------------------------------------------------------------
5 -- This is the default configuration for OXWM, a dynamic window manager.
6 -- Edit this file and reload with Mod+Shift+R (no compilation needed)
7 --
8 -- For more information about configuring OXWM, see the documentation.
9 -- The Lua Language Server provides autocomplete and type checking.
10 -------------------------------------------------------------------------------
11
12 ---Load type definitions for LSP
13 ---@module 'oxwm'
14
15 -------------------------------------------------------------------------------
16 -- Variables
17 -------------------------------------------------------------------------------
18 -- Define your variables here for easy customization throughout the config.
19 -- This makes it simple to change keybindings, colors, and settings in one place.
20
21 -- Modifier key: "Mod4" is the Super/Windows key, "Mod1" is Alt
22 local modkey = "Mod4"
23
24 -- Terminal emulator command (defaults to alacritty)
25 local terminal = "alacritty"
26
27 -- Color palette - customize these to match your theme
28 -- Alternatively you can import other files in here, such as
29 -- local colors = require("colors.lua") and make colors.lua a file
30 -- in the ~/.config/oxwm directory
31 local colors = {
32 fg = "#bbbbbb",
33 red = "#f7768e",
34 bg = "#1a1b26",
35 cyan = "#0db9d7",
36 green = "#9ece6a",
37 lavender = "#a9b1d6",
38 light_blue = "#7aa2f7",
39 grey = "#bbbbbb",
40 blue = "#6dade3",
41 purple = "#ad8ee6",
42 }
43
44 -- Workspace tags - can be numbers, names, or icons (requires a Nerd Font)
45 -- The number of tags is deduced from the size of this table (up to a max of 12).
46 -- The default is 9. To use more, add entries here and uncomment the matching
47 -- keybinds for tags 10-12 further down in this file.
48 local tags = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }
49 -- local tags = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" } -- Example of 12 tags
50 -- local tags = { "", "󰊯", "", "", "󰙯", "󱇤", "", "󱘶", "󰧮" } -- Example of nerd font icon tags
51
52 -- Font for the status bar (use "fc-list" to see available fonts)
53 local bar_font = "monospace:style=Bold:size=10"
54
55 -- Define your blocks
56 -- Similar to widgets in qtile, or dwmblocks
57 local blocks = {
58 oxwm.bar.block.ram({
59 format = "Ram: {used}/{total} GB",
60 interval = 5,
61 color = colors.light_blue,
62 underline = true,
63 }),
64 oxwm.bar.block.static({
65 text = "│",
66 interval = 999999999,
67 color = colors.lavender,
68 underline = false,
69 }),
70 oxwm.bar.block.shell({
71 format = "{}",
72 command = "uname -r",
73 interval = 999999999,
74 color = colors.red,
75 underline = true,
76 }),
77 oxwm.bar.block.static({
78 text = "│",
79 interval = 999999999,
80 color = colors.lavender,
81 underline = false,
82 }),
83 oxwm.bar.block.datetime({
84 format = "{}",
85 date_format = "%a, %b %d - %-I:%M %P",
86 interval = 1,
87 color = colors.cyan,
88 underline = true,
89 }),
90 -- Uncomment to add battery status (useful for laptops)
91 oxwm.bar.block.battery({
92 format = "Bat: {}%",
93 charging = "⚡ Bat: {}%",
94 discharging = "- Bat: {}%",
95 full = "✓ Bat: {}%",
96 interval = 30,
97 color = colors.green,
98 underline = true,
99 -- click: run a command when the block is clicked
100 -- click = "alacritty -e btop",
101 -- click = { command = "bluetui", floating = true },
102 }),
103 };
104
105 -------------------------------------------------------------------------------
106 -- Basic Settings
107 -------------------------------------------------------------------------------
108 oxwm.set_terminal(terminal)
109 oxwm.set_modkey(modkey) -- This is for Mod + mouse binds, such as drag/resize
110 oxwm.set_tags(tags)
111
112 -- Set default layout (tiling by default)
113 -- oxwm.set_layout("tiling")
114
115 -------------------------------------------------------------------------------
116 -- Layouts
117 -------------------------------------------------------------------------------
118 -- Set custom symbols for layouts (displayed in the status bar)
119 -- Available layouts: "tiling", "normie" (floating), "grid", "monocle", "tabbed", "dwindle"
120 oxwm.set_layout_symbol("tiling", "[T]")
121 oxwm.set_layout_symbol("normie", "[F]")
122 oxwm.set_layout_symbol("tabbed", "[=]")
123 -- oxwm.set_layout_symbol("dwindle", "[\\]")
124
125 -- Example: bind dwindle (fibonacci) layout
126 -- oxwm.key.bind({ modkey }, "R", oxwm.layout.set("dwindle"))
127
128 -- Set default layout of specific tag (tag_index, layout_name)
129 -- Unset value uses oxwm.set_layout value
130 -- oxwm.set_tag_layout(1, "grid")
131
132 -- Scrolling layout: windows sit side by side in an infinite strip (like niri)
133 -- Widths at or below 1 are a proportion of the screen, larger values are pixels
134 -- oxwm.scroll.set_default_width(0.5)
135 -- oxwm.scroll.set_width_presets({ 1 / 3, 1 / 2, 2 / 3 })
136 -- Three-finger touchpad swipes scroll the strip and snap to the nearest window
137 -- (needs read access to /dev/input, usually the "input" group)
138 -- oxwm.scroll.set_gesture_enabled(true)
139 -- oxwm.scroll.set_gesture_fingers(3)
140 -- oxwm.scroll.set_gesture_speed(2.0)
141 -- oxwm.scroll.set_gesture_natural(false)
142 -- Minimap of the strip in the bar (one box per window, focused highlighted)
143 -- oxwm.scroll.set_indicator(true)
144 -- oxwm.scroll.set_indicator_width(0) -- pixels, 0 = 4x bar height
145
146 -- Set the default attach method, similar to the patches from dwm
147 -- Available methods: "aside" (default), "top", "bottom", "above", "below"
148 -- For example "above" makes new clients appear above the currently selected one
149 oxwm.set_attach_method("aside")
150
151 -------------------------------------------------------------------------------
152 -- Appearance
153 -------------------------------------------------------------------------------
154 -- Border configuration
155
156 -- Width in pixels
157 oxwm.border.set_width(2)
158 -- Color of focused window border
159 oxwm.border.set_focused_color(colors.blue)
160 -- Color of unfocused window borders
161 oxwm.border.set_unfocused_color(colors.grey)
162
163 -- Where floating windows spawn: "top-left", "top-center", "top-right",
164 -- "center-left", "center", "center-right", "bottom-left", "bottom-center", "bottom-right"
165 oxwm.set_floating_position("center")
166
167 -- Smart Enabled = No border if 1 window
168 oxwm.gaps.set_smart(true)
169 -- Inner gaps (horizontal, vertical) in pixels
170 oxwm.gaps.set_inner(5, 5)
171 -- Outer gaps (horizontal, vertical) in pixels
172 oxwm.gaps.set_outer(5, 5)
173
174 -------------------------------------------------------------------------------
175 -- Window Rules
176 -------------------------------------------------------------------------------
177 -- Rules allow you to automatically configure windows based on their properties
178 -- You can match windows by class, instance, title, or role
179 -- Available properties: floating, tag, fullscreen, etc.
180 --
181 -- Common use cases:
182 -- - Force floating for certain applications (dialogs, utilities)
183 -- - Send specific applications to specific workspaces
184 -- - Configure window behavior based on title or class
185
186 -- Examples (uncomment to use):
187 oxwm.rule.add({ instance = "gimp", floating = true })
188 -- oxwm.rule.add({ class = "Alacritty", tag = 9, focus = true })
189 -- oxwm.rule.add({ class = "firefox", title = "Library", floating = true })
190 -- oxwm.rule.add({ class = "firefox", tag = 2 })
191 -- oxwm.rule.add({ instance = "mpv", floating = true })
192
193 -- To find window properties, use xprop and click on the window
194 -- WM_CLASS(STRING) shows both instance and class (instance, class)
195
196 -------------------------------------------------------------------------------
197 -- Status Bar Configuration
198 -------------------------------------------------------------------------------
199 -- Font configuration
200 oxwm.bar.set_font(bar_font)
201
202 -- Position configuration (top/bottom, top is default)
203 -- oxwm.bar.set_position("bottom")
204
205 -- Set your blocks here (defined above)
206 oxwm.bar.set_blocks(blocks)
207
208 -- Bar color schemes (for workspace tag display)
209 -- Parameters: foreground, background, border
210
211 -- Unoccupied tags
212 oxwm.bar.set_scheme_normal(colors.fg, colors.bg, "#444444")
213 -- Occupied tags
214 oxwm.bar.set_scheme_occupied(colors.cyan, colors.bg, colors.cyan)
215 -- Currently selected tag
216 oxwm.bar.set_scheme_selected(colors.cyan, colors.bg, colors.purple)
217 -- Urgent tags (windows requesting attention)
218 oxwm.bar.set_scheme_urgent(colors.red, colors.bg, colors.red)
219
220 -- Hide tags that have no windows and are not selected
221 -- oxwm.bar.set_hide_vacant_tags(true)
222
223 -------------------------------------------------------------------------------
224 -- Keybindings
225 -------------------------------------------------------------------------------
226 -- Keybindings are defined using oxwm.key.bind(modifiers, key, action)
227 -- Modifiers: {"Mod4"}, {"Mod1"}, {"Shift"}, {"Control"}, or combinations like {"Mod4", "Shift"}
228 -- Keys: Use uppercase for letters (e.g., "Return", "H", "J", "K", "L")
229 -- Actions: Functions that return actions (e.g., oxwm.spawn(), oxwm.client.kill())
230 --
231 -- A list of available keysyms can be found in the X11 keysym definitions.
232 -- Common keys: Return, Space, Tab, Escape, Backspace, Delete, Left, Right, Up, Down
233
234 -- Basic window management
235
236 oxwm.key.bind({ modkey }, "Return", oxwm.spawn_terminal())
237 -- Launch Dmenu
238 oxwm.key.bind({ modkey }, "D", oxwm.spawn({ "sh", "-c", "dmenu_run -l 10" }))
239 -- Copy screenshot to clipboard
240 oxwm.key.bind({ modkey }, "S", oxwm.spawn({ "sh", "-c", "maim -s | xclip -selection clipboard -t image/png" }))
241 oxwm.key.bind({ modkey }, "Q", oxwm.client.kill())
242
243 -- Keybind overlay - Shows important keybindings on screen
244 oxwm.key.bind({ modkey, "Shift" }, "Slash", oxwm.show_keybinds())
245
246 -- Window state toggles
247 oxwm.key.bind({ modkey, "Shift" }, "F", oxwm.client.toggle_fullscreen())
248 oxwm.key.bind({ modkey, "Shift" }, "Space", oxwm.client.toggle_floating())
249
250 -- Layout management
251 oxwm.key.bind({ modkey }, "F", oxwm.layout.set("normie"))
252 oxwm.key.bind({ modkey }, "C", oxwm.layout.set("tiling"))
253 -- Cycle through layouts
254 oxwm.key.bind({ modkey }, "N", oxwm.layout.cycle())
255
256 -- Scrolling layout controls
257 -- oxwm.key.bind({ modkey }, "G", oxwm.layout.set("scrolling"))
258 -- oxwm.key.bind({ modkey }, "Left", oxwm.layout.scroll_left())
259 -- oxwm.key.bind({ modkey }, "Right", oxwm.layout.scroll_right())
260 -- oxwm.key.bind({ modkey }, "R", oxwm.layout.cycle_width(1))
261 -- oxwm.key.bind({ modkey, "Shift" }, "R", oxwm.layout.cycle_width(-1))
262 -- oxwm.key.bind({ modkey }, "M", oxwm.layout.set_width(1))
263 -- In the scrolling layout set_master_factor resizes the focused window instead
264
265 -- Master area controls (tiling layout)
266
267 -- Decrease/Increase master area width
268 oxwm.key.bind({ modkey }, "H", oxwm.set_master_factor(-5))
269 oxwm.key.bind({ modkey }, "L", oxwm.set_master_factor(5))
270 -- Enable tiled resize mode: Mod+RMB drag adjusts mfact instead of floating
271 -- oxwm.tiled_resize_mode(true)
272 -- Increment/Decrement number of master windows
273 oxwm.key.bind({ modkey }, "I", oxwm.inc_num_master(1))
274 oxwm.key.bind({ modkey }, "P", oxwm.inc_num_master(-1))
275
276 -- Gaps toggle
277 oxwm.key.bind({ modkey }, "A", oxwm.toggle_gaps())
278 -- Bar toggle
279 oxwm.key.bind({ modkey }, "B", oxwm.toggle_bar())
280
281 -- Window manager controls
282 oxwm.key.bind({ modkey, "Shift" }, "Q", oxwm.quit())
283 oxwm.key.bind({ modkey, "Shift" }, "R", oxwm.restart())
284
285 -- Focus movement [1 for up in the stack, -1 for down]
286 oxwm.key.bind({ modkey }, "J", oxwm.client.focus_stack(1))
287 oxwm.key.bind({ modkey }, "K", oxwm.client.focus_stack(-1))
288
289 -- Window movement (swap position in stack)
290 oxwm.key.bind({ modkey, "Shift" }, "J", oxwm.client.move_stack(1))
291 oxwm.key.bind({ modkey, "Shift" }, "K", oxwm.client.move_stack(-1))
292
293 -- Multi-monitor support
294
295 -- Focus next/previous Monitors
296 oxwm.key.bind({ modkey }, "Comma", oxwm.monitor.focus(-1))
297 oxwm.key.bind({ modkey }, "Period", oxwm.monitor.focus(1))
298 -- Move window to next/previous Monitors
299 oxwm.key.bind({ modkey, "Shift" }, "Comma", oxwm.monitor.tag(-1))
300 oxwm.key.bind({ modkey, "Shift" }, "Period", oxwm.monitor.tag(1))
301
302 -- Warp the cursor to the focused monitor when switching monitors
303 -- oxwm.monitor.warp_cursor(true)
304 -- Warp the cursor along when sending a window to another monitor
305 -- oxwm.monitor.warp_cursor_on_send(true)
306
307 -- Workspace (tag) navigation
308 -- Switch to workspace N (tags are 0-indexed, so tag "1" is index 0)
309 oxwm.key.bind({ modkey }, "1", oxwm.tag.view(0))
310 oxwm.key.bind({ modkey }, "2", oxwm.tag.view(1))
311 oxwm.key.bind({ modkey }, "3", oxwm.tag.view(2))
312 oxwm.key.bind({ modkey }, "4", oxwm.tag.view(3))
313 oxwm.key.bind({ modkey }, "5", oxwm.tag.view(4))
314 oxwm.key.bind({ modkey }, "6", oxwm.tag.view(5))
315 oxwm.key.bind({ modkey }, "7", oxwm.tag.view(6))
316 oxwm.key.bind({ modkey }, "8", oxwm.tag.view(7))
317 oxwm.key.bind({ modkey }, "9", oxwm.tag.view(8))
318 -- Tags 10-12 (opt-in): set 12 tags above, then pick keys you like and uncomment.
319 -- oxwm.key.bind({ modkey }, "0", oxwm.tag.view(9))
320 -- oxwm.key.bind({ modkey }, "minus", oxwm.tag.view(10))
321 -- oxwm.key.bind({ modkey }, "equal", oxwm.tag.view(11))
322
323 -- Move focused window to workspace N
324 oxwm.key.bind({ modkey, "Shift" }, "1", oxwm.tag.move_to(0))
325 oxwm.key.bind({ modkey, "Shift" }, "2", oxwm.tag.move_to(1))
326 oxwm.key.bind({ modkey, "Shift" }, "3", oxwm.tag.move_to(2))
327 oxwm.key.bind({ modkey, "Shift" }, "4", oxwm.tag.move_to(3))
328 oxwm.key.bind({ modkey, "Shift" }, "5", oxwm.tag.move_to(4))
329 oxwm.key.bind({ modkey, "Shift" }, "6", oxwm.tag.move_to(5))
330 oxwm.key.bind({ modkey, "Shift" }, "7", oxwm.tag.move_to(6))
331 oxwm.key.bind({ modkey, "Shift" }, "8", oxwm.tag.move_to(7))
332 oxwm.key.bind({ modkey, "Shift" }, "9", oxwm.tag.move_to(8))
333 -- oxwm.key.bind({ modkey, "Shift" }, "0", oxwm.tag.move_to(9))
334 -- oxwm.key.bind({ modkey, "Shift" }, "minus", oxwm.tag.move_to(10))
335 -- oxwm.key.bind({ modkey, "Shift" }, "equal", oxwm.tag.move_to(11))
336
337 -- Combo view (view multiple tags at once) {argos_nothing}
338 -- Example: Mod+Ctrl+2 while on tag 1 will show BOTH tags 1 and 2
339 oxwm.key.bind({ modkey, "Control" }, "1", oxwm.tag.toggleview(0))
340 oxwm.key.bind({ modkey, "Control" }, "2", oxwm.tag.toggleview(1))
341 oxwm.key.bind({ modkey, "Control" }, "3", oxwm.tag.toggleview(2))
342 oxwm.key.bind({ modkey, "Control" }, "4", oxwm.tag.toggleview(3))
343 oxwm.key.bind({ modkey, "Control" }, "5", oxwm.tag.toggleview(4))
344 oxwm.key.bind({ modkey, "Control" }, "6", oxwm.tag.toggleview(5))
345 oxwm.key.bind({ modkey, "Control" }, "7", oxwm.tag.toggleview(6))
346 oxwm.key.bind({ modkey, "Control" }, "8", oxwm.tag.toggleview(7))
347 oxwm.key.bind({ modkey, "Control" }, "9", oxwm.tag.toggleview(8))
348 -- oxwm.key.bind({ modkey, "Control" }, "0", oxwm.tag.toggleview(9))
349 -- oxwm.key.bind({ modkey, "Control" }, "minus", oxwm.tag.toggleview(10))
350 -- oxwm.key.bind({ modkey, "Control" }, "equal", oxwm.tag.toggleview(11))
351
352 -- Multi tag (window on multiple tags)
353 -- Example: Mod+Ctrl+Shift+2 puts focused window on BOTH current tag and tag 2
354 oxwm.key.bind({ modkey, "Control", "Shift" }, "1", oxwm.tag.toggletag(0))
355 oxwm.key.bind({ modkey, "Control", "Shift" }, "2", oxwm.tag.toggletag(1))
356 oxwm.key.bind({ modkey, "Control", "Shift" }, "3", oxwm.tag.toggletag(2))
357 oxwm.key.bind({ modkey, "Control", "Shift" }, "4", oxwm.tag.toggletag(3))
358 oxwm.key.bind({ modkey, "Control", "Shift" }, "5", oxwm.tag.toggletag(4))
359 oxwm.key.bind({ modkey, "Control", "Shift" }, "6", oxwm.tag.toggletag(5))
360 oxwm.key.bind({ modkey, "Control", "Shift" }, "7", oxwm.tag.toggletag(6))
361 oxwm.key.bind({ modkey, "Control", "Shift" }, "8", oxwm.tag.toggletag(7))
362 oxwm.key.bind({ modkey, "Control", "Shift" }, "9", oxwm.tag.toggletag(8))
363 -- oxwm.key.bind({ modkey, "Control", "Shift" }, "0", oxwm.tag.toggletag(9))
364 -- oxwm.key.bind({ modkey, "Control", "Shift" }, "minus", oxwm.tag.toggletag(10))
365 -- oxwm.key.bind({ modkey, "Control", "Shift" }, "equal", oxwm.tag.toggletag(11))
366
367 -------------------------------------------------------------------------------
368 -- Advanced: Keychords
369 -------------------------------------------------------------------------------
370 -- Keychords allow you to bind multiple-key sequences (like Emacs or Vim)
371 -- Format: {{modifiers}, key1}, {{modifiers}, key2}, ...
372 -- Example: Press Mod4+Space, then release and press T to spawn a terminal
373 oxwm.key.chord({
374 { { modkey }, "Space" },
375 { {}, "T" }
376 }, oxwm.spawn_terminal())
377
378 -------------------------------------------------------------------------------
379 -- Autostart
380 -------------------------------------------------------------------------------
381 -- Commands to run once when OXWM starts
382 -- Uncomment and modify these examples, or add your own
383
384 -- oxwm.autostart("picom")
385 -- oxwm.autostart("feh --bg-scale ~/wallpaper.jpg")
386 -- oxwm.autostart("dunst")
387 -- oxwm.autostart("nm-applet")