tony / oxwm

Branch: master
Switch branches/tags
master
tonybanters added default info to default config for toggle-able bar and gestures. a96a42b 24d ago
388 lines · 16.4 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 -- Off by default. Uncomment this to enable trackpad gestures
138 -- (needs libinput at build time and read access to /dev/input, usually the "input" group)
139 -- oxwm.scroll.set_gesture_enabled(true)
140 -- oxwm.scroll.set_gesture_fingers(3)
141 -- oxwm.scroll.set_gesture_speed(2.0)
142 -- oxwm.scroll.set_gesture_natural(false)
143 -- Minimap of the strip in the bar (one box per window, focused highlighted)
144 -- oxwm.scroll.set_indicator(true)
145 -- oxwm.scroll.set_indicator_width(0) -- pixels, 0 = 4x bar height
146
147 -- Set the default attach method, similar to the patches from dwm
148 -- Available methods: "aside" (default), "top", "bottom", "above", "below"
149 -- For example "above" makes new clients appear above the currently selected one
150 oxwm.set_attach_method("aside")
151
152 -------------------------------------------------------------------------------
153 -- Appearance
154 -------------------------------------------------------------------------------
155 -- Border configuration
156
157 -- Width in pixels
158 oxwm.border.set_width(2)
159 -- Color of focused window border
160 oxwm.border.set_focused_color(colors.blue)
161 -- Color of unfocused window borders
162 oxwm.border.set_unfocused_color(colors.grey)
163
164 -- Where floating windows spawn: "top-left", "top-center", "top-right",
165 -- "center-left", "center", "center-right", "bottom-left", "bottom-center", "bottom-right"
166 oxwm.set_floating_position("center")
167
168 -- Smart Enabled = No border if 1 window
169 oxwm.gaps.set_smart(true)
170 -- Inner gaps (horizontal, vertical) in pixels
171 oxwm.gaps.set_inner(5, 5)
172 -- Outer gaps (horizontal, vertical) in pixels
173 oxwm.gaps.set_outer(5, 5)
174
175 -------------------------------------------------------------------------------
176 -- Window Rules
177 -------------------------------------------------------------------------------
178 -- Rules allow you to automatically configure windows based on their properties
179 -- You can match windows by class, instance, title, or role
180 -- Available properties: floating, tag, fullscreen, etc.
181 --
182 -- Common use cases:
183 -- - Force floating for certain applications (dialogs, utilities)
184 -- - Send specific applications to specific workspaces
185 -- - Configure window behavior based on title or class
186
187 -- Examples (uncomment to use):
188 oxwm.rule.add({ instance = "gimp", floating = true })
189 -- oxwm.rule.add({ class = "Alacritty", tag = 9, focus = true })
190 -- oxwm.rule.add({ class = "firefox", title = "Library", floating = true })
191 -- oxwm.rule.add({ class = "firefox", tag = 2 })
192 -- oxwm.rule.add({ instance = "mpv", floating = true })
193
194 -- To find window properties, use xprop and click on the window
195 -- WM_CLASS(STRING) shows both instance and class (instance, class)
196
197 -------------------------------------------------------------------------------
198 -- Status Bar Configuration
199 -------------------------------------------------------------------------------
200 -- Font configuration
201 oxwm.bar.set_font(bar_font)
202
203 -- Position configuration (top/bottom, top is default)
204 -- oxwm.bar.set_position("bottom")
205
206 -- Set your blocks here (defined above)
207 oxwm.bar.set_blocks(blocks)
208
209 -- Bar color schemes (for workspace tag display)
210 -- Parameters: foreground, background, border
211
212 -- Unoccupied tags
213 oxwm.bar.set_scheme_normal(colors.fg, colors.bg, "#444444")
214 -- Occupied tags
215 oxwm.bar.set_scheme_occupied(colors.cyan, colors.bg, colors.cyan)
216 -- Currently selected tag
217 oxwm.bar.set_scheme_selected(colors.cyan, colors.bg, colors.purple)
218 -- Urgent tags (windows requesting attention)
219 oxwm.bar.set_scheme_urgent(colors.red, colors.bg, colors.red)
220
221 -- Hide tags that have no windows and are not selected
222 -- oxwm.bar.set_hide_vacant_tags(true)
223
224 -------------------------------------------------------------------------------
225 -- Keybindings
226 -------------------------------------------------------------------------------
227 -- Keybindings are defined using oxwm.key.bind(modifiers, key, action)
228 -- Modifiers: {"Mod4"}, {"Mod1"}, {"Shift"}, {"Control"}, or combinations like {"Mod4", "Shift"}
229 -- Keys: Use uppercase for letters (e.g., "Return", "H", "J", "K", "L")
230 -- Actions: Functions that return actions (e.g., oxwm.spawn(), oxwm.client.kill())
231 --
232 -- A list of available keysyms can be found in the X11 keysym definitions.
233 -- Common keys: Return, Space, Tab, Escape, Backspace, Delete, Left, Right, Up, Down
234
235 -- Basic window management
236
237 oxwm.key.bind({ modkey }, "Return", oxwm.spawn_terminal())
238 -- Launch Dmenu
239 oxwm.key.bind({ modkey }, "D", oxwm.spawn({ "sh", "-c", "dmenu_run -l 10" }))
240 -- Copy screenshot to clipboard
241 oxwm.key.bind({ modkey }, "S", oxwm.spawn({ "sh", "-c", "maim -s | xclip -selection clipboard -t image/png" }))
242 oxwm.key.bind({ modkey }, "Q", oxwm.client.kill())
243
244 -- Keybind overlay - Shows important keybindings on screen
245 oxwm.key.bind({ modkey, "Shift" }, "Slash", oxwm.show_keybinds())
246
247 -- Window state toggles
248 oxwm.key.bind({ modkey, "Shift" }, "F", oxwm.client.toggle_fullscreen())
249 oxwm.key.bind({ modkey, "Shift" }, "Space", oxwm.client.toggle_floating())
250
251 -- Layout management
252 oxwm.key.bind({ modkey }, "F", oxwm.layout.set("normie"))
253 oxwm.key.bind({ modkey }, "C", oxwm.layout.set("tiling"))
254 -- Cycle through layouts
255 oxwm.key.bind({ modkey }, "N", oxwm.layout.cycle())
256
257 -- Scrolling layout controls
258 -- oxwm.key.bind({ modkey }, "G", oxwm.layout.set("scrolling"))
259 -- oxwm.key.bind({ modkey }, "Left", oxwm.layout.scroll_left())
260 -- oxwm.key.bind({ modkey }, "Right", oxwm.layout.scroll_right())
261 -- oxwm.key.bind({ modkey }, "R", oxwm.layout.cycle_width(1))
262 -- oxwm.key.bind({ modkey, "Shift" }, "R", oxwm.layout.cycle_width(-1))
263 -- oxwm.key.bind({ modkey }, "M", oxwm.layout.set_width(1))
264 -- In the scrolling layout set_master_factor resizes the focused window instead
265
266 -- Master area controls (tiling layout)
267
268 -- Decrease/Increase master area width
269 oxwm.key.bind({ modkey }, "H", oxwm.set_master_factor(-5))
270 oxwm.key.bind({ modkey }, "L", oxwm.set_master_factor(5))
271 -- Enable tiled resize mode: Mod+RMB drag adjusts mfact instead of floating
272 -- oxwm.tiled_resize_mode(true)
273 -- Increment/Decrement number of master windows
274 oxwm.key.bind({ modkey }, "I", oxwm.inc_num_master(1))
275 oxwm.key.bind({ modkey }, "P", oxwm.inc_num_master(-1))
276
277 -- Gaps toggle
278 oxwm.key.bind({ modkey }, "A", oxwm.toggle_gaps())
279 -- Bar toggle
280 oxwm.key.bind({ modkey }, "B", oxwm.toggle_bar())
281
282 -- Window manager controls
283 oxwm.key.bind({ modkey, "Shift" }, "Q", oxwm.quit())
284 oxwm.key.bind({ modkey, "Shift" }, "R", oxwm.restart())
285
286 -- Focus movement [1 for up in the stack, -1 for down]
287 oxwm.key.bind({ modkey }, "J", oxwm.client.focus_stack(1))
288 oxwm.key.bind({ modkey }, "K", oxwm.client.focus_stack(-1))
289
290 -- Window movement (swap position in stack)
291 oxwm.key.bind({ modkey, "Shift" }, "J", oxwm.client.move_stack(1))
292 oxwm.key.bind({ modkey, "Shift" }, "K", oxwm.client.move_stack(-1))
293
294 -- Multi-monitor support
295
296 -- Focus next/previous Monitors
297 oxwm.key.bind({ modkey }, "Comma", oxwm.monitor.focus(-1))
298 oxwm.key.bind({ modkey }, "Period", oxwm.monitor.focus(1))
299 -- Move window to next/previous Monitors
300 oxwm.key.bind({ modkey, "Shift" }, "Comma", oxwm.monitor.tag(-1))
301 oxwm.key.bind({ modkey, "Shift" }, "Period", oxwm.monitor.tag(1))
302
303 -- Warp the cursor to the focused monitor when switching monitors
304 -- oxwm.monitor.warp_cursor(true)
305 -- Warp the cursor along when sending a window to another monitor
306 -- oxwm.monitor.warp_cursor_on_send(true)
307
308 -- Workspace (tag) navigation
309 -- Switch to workspace N (tags are 0-indexed, so tag "1" is index 0)
310 oxwm.key.bind({ modkey }, "1", oxwm.tag.view(0))
311 oxwm.key.bind({ modkey }, "2", oxwm.tag.view(1))
312 oxwm.key.bind({ modkey }, "3", oxwm.tag.view(2))
313 oxwm.key.bind({ modkey }, "4", oxwm.tag.view(3))
314 oxwm.key.bind({ modkey }, "5", oxwm.tag.view(4))
315 oxwm.key.bind({ modkey }, "6", oxwm.tag.view(5))
316 oxwm.key.bind({ modkey }, "7", oxwm.tag.view(6))
317 oxwm.key.bind({ modkey }, "8", oxwm.tag.view(7))
318 oxwm.key.bind({ modkey }, "9", oxwm.tag.view(8))
319 -- Tags 10-12 (opt-in): set 12 tags above, then pick keys you like and uncomment.
320 -- oxwm.key.bind({ modkey }, "0", oxwm.tag.view(9))
321 -- oxwm.key.bind({ modkey }, "minus", oxwm.tag.view(10))
322 -- oxwm.key.bind({ modkey }, "equal", oxwm.tag.view(11))
323
324 -- Move focused window to workspace N
325 oxwm.key.bind({ modkey, "Shift" }, "1", oxwm.tag.move_to(0))
326 oxwm.key.bind({ modkey, "Shift" }, "2", oxwm.tag.move_to(1))
327 oxwm.key.bind({ modkey, "Shift" }, "3", oxwm.tag.move_to(2))
328 oxwm.key.bind({ modkey, "Shift" }, "4", oxwm.tag.move_to(3))
329 oxwm.key.bind({ modkey, "Shift" }, "5", oxwm.tag.move_to(4))
330 oxwm.key.bind({ modkey, "Shift" }, "6", oxwm.tag.move_to(5))
331 oxwm.key.bind({ modkey, "Shift" }, "7", oxwm.tag.move_to(6))
332 oxwm.key.bind({ modkey, "Shift" }, "8", oxwm.tag.move_to(7))
333 oxwm.key.bind({ modkey, "Shift" }, "9", oxwm.tag.move_to(8))
334 -- oxwm.key.bind({ modkey, "Shift" }, "0", oxwm.tag.move_to(9))
335 -- oxwm.key.bind({ modkey, "Shift" }, "minus", oxwm.tag.move_to(10))
336 -- oxwm.key.bind({ modkey, "Shift" }, "equal", oxwm.tag.move_to(11))
337
338 -- Combo view (view multiple tags at once) {argos_nothing}
339 -- Example: Mod+Ctrl+2 while on tag 1 will show BOTH tags 1 and 2
340 oxwm.key.bind({ modkey, "Control" }, "1", oxwm.tag.toggleview(0))
341 oxwm.key.bind({ modkey, "Control" }, "2", oxwm.tag.toggleview(1))
342 oxwm.key.bind({ modkey, "Control" }, "3", oxwm.tag.toggleview(2))
343 oxwm.key.bind({ modkey, "Control" }, "4", oxwm.tag.toggleview(3))
344 oxwm.key.bind({ modkey, "Control" }, "5", oxwm.tag.toggleview(4))
345 oxwm.key.bind({ modkey, "Control" }, "6", oxwm.tag.toggleview(5))
346 oxwm.key.bind({ modkey, "Control" }, "7", oxwm.tag.toggleview(6))
347 oxwm.key.bind({ modkey, "Control" }, "8", oxwm.tag.toggleview(7))
348 oxwm.key.bind({ modkey, "Control" }, "9", oxwm.tag.toggleview(8))
349 -- oxwm.key.bind({ modkey, "Control" }, "0", oxwm.tag.toggleview(9))
350 -- oxwm.key.bind({ modkey, "Control" }, "minus", oxwm.tag.toggleview(10))
351 -- oxwm.key.bind({ modkey, "Control" }, "equal", oxwm.tag.toggleview(11))
352
353 -- Multi tag (window on multiple tags)
354 -- Example: Mod+Ctrl+Shift+2 puts focused window on BOTH current tag and tag 2
355 oxwm.key.bind({ modkey, "Control", "Shift" }, "1", oxwm.tag.toggletag(0))
356 oxwm.key.bind({ modkey, "Control", "Shift" }, "2", oxwm.tag.toggletag(1))
357 oxwm.key.bind({ modkey, "Control", "Shift" }, "3", oxwm.tag.toggletag(2))
358 oxwm.key.bind({ modkey, "Control", "Shift" }, "4", oxwm.tag.toggletag(3))
359 oxwm.key.bind({ modkey, "Control", "Shift" }, "5", oxwm.tag.toggletag(4))
360 oxwm.key.bind({ modkey, "Control", "Shift" }, "6", oxwm.tag.toggletag(5))
361 oxwm.key.bind({ modkey, "Control", "Shift" }, "7", oxwm.tag.toggletag(6))
362 oxwm.key.bind({ modkey, "Control", "Shift" }, "8", oxwm.tag.toggletag(7))
363 oxwm.key.bind({ modkey, "Control", "Shift" }, "9", oxwm.tag.toggletag(8))
364 -- oxwm.key.bind({ modkey, "Control", "Shift" }, "0", oxwm.tag.toggletag(9))
365 -- oxwm.key.bind({ modkey, "Control", "Shift" }, "minus", oxwm.tag.toggletag(10))
366 -- oxwm.key.bind({ modkey, "Control", "Shift" }, "equal", oxwm.tag.toggletag(11))
367
368 -------------------------------------------------------------------------------
369 -- Advanced: Keychords
370 -------------------------------------------------------------------------------
371 -- Keychords allow you to bind multiple-key sequences (like Emacs or Vim)
372 -- Format: {{modifiers}, key1}, {{modifiers}, key2}, ...
373 -- Example: Press Mod4+Space, then release and press T to spawn a terminal
374 oxwm.key.chord({
375 { { modkey }, "Space" },
376 { {}, "T" }
377 }, oxwm.spawn_terminal())
378
379 -------------------------------------------------------------------------------
380 -- Autostart
381 -------------------------------------------------------------------------------
382 -- Commands to run once when OXWM starts
383 -- Uncomment and modify these examples, or add your own
384
385 -- oxwm.autostart("picom")
386 -- oxwm.autostart("feh --bg-scale ~/wallpaper.jpg")
387 -- oxwm.autostart("dunst")
388 -- oxwm.autostart("nm-applet")