oxwm

https://git.tonybtw.com/oxwm.git git://git.tonybtw.com/oxwm.git
12,535 bytes raw
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 (defualts 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
local tags = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }
46
-- local tags = { "", "󰊯", "", "", "󰙯", "󱇤", "", "󱘶", "󰧮" } -- Example of nerd font icon tags
47
48
-- Font for the status bar (use "fc-list" to see available fonts)
49
local bar_font = "monospace:style=Bold:size=10"
50
51
-- Define your blocks
52
-- Similar to widgets in qtile, or dwmblocks
53
local blocks = {
54
    oxwm.bar.block.ram({
55
        format = "Ram: {used}/{total} GB",
56
        interval = 5,
57
        color = colors.light_blue,
58
        underline = true,
59
    }),
60
    oxwm.bar.block.static({
61
        text = " │  ",
62
        interval = 999999999,
63
        color = colors.lavender,
64
        underline = false,
65
    }),
66
    oxwm.bar.block.shell({
67
        command = "uname -r",
68
        interval = 999999999,
69
        color = colors.red,
70
        underline = true,
71
    }),
72
    oxwm.bar.block.static({
73
        text = " │  ",
74
        interval = 999999999,
75
        color = colors.lavender,
76
        underline = false,
77
    }),
78
    oxwm.bar.block.datetime({
79
        date_format = "%a, %b %d - %-I:%M %P",
80
        interval = 1,
81
        color = colors.cyan,
82
        underline = true,
83
    }),
84
    -- Uncomment to add battery status (useful for laptops)
85
    -- oxwm.bar.block.battery({
86
    --     format = "Bat: {}%",
87
    --     charging = "⚡ Bat: {}%",
88
    --     discharging = "- Bat: {}%",
89
    --     full = "✓ Bat: {}%",
90
    --     interval = 30,
91
    --     color = colors.green,
92
    --     underline = true,
93
    -- }),
94
};
95
96
-------------------------------------------------------------------------------
97
-- Basic Settings
98
-------------------------------------------------------------------------------
99
oxwm.set_terminal(terminal)
100
oxwm.set_modkey(modkey) -- This is for Mod + mouse binds, such as drag/resize
101
oxwm.set_tags(tags)
102
103
-------------------------------------------------------------------------------
104
-- Layouts
105
-------------------------------------------------------------------------------
106
-- Set custom symbols for layouts (displayed in the status bar)
107
-- Available layouts: "tiling", "normie" (floating), "grid", "monocle", "tabbed"
108
oxwm.set_layout_symbol("tiling", "[T]")
109
oxwm.set_layout_symbol("normie", "[F]")
110
oxwm.set_layout_symbol("tabbed", "[=]")
111
112
-------------------------------------------------------------------------------
113
-- Appearance
114
-------------------------------------------------------------------------------
115
-- Border configuration
116
117
-- Width in pixels
118
oxwm.border.set_width(2)
119
-- Color of focused window border
120
oxwm.border.set_focused_color(colors.blue)
121
-- Color of unfocused window borders
122
oxwm.border.set_unfocused_color(colors.grey)
123
124
-- Smart Enabled = No border if 1 window
125
oxwm.gaps.set_smart(enabled)
126
-- Inner gaps (horizontal, vertical) in pixels
127
oxwm.gaps.set_inner(5, 5)
128
-- Outer gaps (horizontal, vertical) in pixels
129
oxwm.gaps.set_outer(5, 5)
130
131
-------------------------------------------------------------------------------
132
-- Window Rules
133
-------------------------------------------------------------------------------
134
-- Rules allow you to automatically configure windows based on their properties
135
-- You can match windows by class, instance, title, or role
136
-- Available properties: floating, tag, fullscreen, etc.
137
--
138
-- Common use cases:
139
-- - Force floating for certain applications (dialogs, utilities)
140
-- - Send specific applications to specific workspaces
141
-- - Configure window behavior based on title or class
142
143
-- Examples (uncomment to use):
144
oxwm.rule.add({ instance = "gimp", floating = true })                             
145
-- oxwm.rule.add({ class = "firefox", title = "Library", floating = true })  
146
-- oxwm.rule.add({ instance = "mpv", floating = true })                      
147
148
-- To find window properties, use xprop and click on the window
149
-- WM_CLASS(STRING) shows both instance and class (instance, class)
150
151
-------------------------------------------------------------------------------
152
-- Status Bar Configuration
153
-------------------------------------------------------------------------------
154
-- Font configuration
155
oxwm.bar.set_font(bar_font)
156
157
-- Set your blocks here (defined above)
158
oxwm.bar.set_blocks(blocks)
159
160
-- Bar color schemes (for workspace tag display)
161
-- Parameters: foreground, background, border
162
163
-- Unoccupied tags
164
oxwm.bar.set_scheme_normal(colors.fg, colors.bg, "#444444")
165
-- Occupied tags
166
oxwm.bar.set_scheme_occupied(colors.cyan, colors.bg, colors.cyan)
167
-- Currently selected tag
168
oxwm.bar.set_scheme_selected(colors.cyan, colors.bg, colors.purple)
169
170
-------------------------------------------------------------------------------
171
-- Keybindings
172
-------------------------------------------------------------------------------
173
-- Keybindings are defined using oxwm.key.bind(modifiers, key, action)
174
-- Modifiers: {"Mod4"}, {"Mod1"}, {"Shift"}, {"Control"}, or combinations like {"Mod4", "Shift"}
175
-- Keys: Use uppercase for letters (e.g., "Return", "H", "J", "K", "L")
176
-- Actions: Functions that return actions (e.g., oxwm.spawn(), oxwm.client.kill())
177
--
178
-- A list of available keysyms can be found in the X11 keysym definitions.
179
-- Common keys: Return, Space, Tab, Escape, Backspace, Delete, Left, Right, Up, Down
180
181
-- Basic window management
182
183
oxwm.key.bind({ modkey }, "Return", oxwm.spawn_terminal())
184
-- Launch Dmenu
185
oxwm.key.bind({ modkey }, "D", oxwm.spawn({ "sh", "-c", "dmenu_run -l 10" }))
186
-- Copy screenshot to clipboard
187
oxwm.key.bind({ modkey }, "S", oxwm.spawn({ "sh", "-c", "maim -s | xclip -selection clipboard -t image/png" }))
188
oxwm.key.bind({ modkey }, "Q", oxwm.client.kill()) 
189
190
-- Keybind overlay - Shows important keybindings on screen
191
oxwm.key.bind({ modkey, "Shift" }, "Slash", oxwm.show_keybinds())
192
193
-- Window state toggles
194
oxwm.key.bind({ modkey, "Shift" }, "F", oxwm.client.toggle_fullscreen())
195
oxwm.key.bind({ modkey, "Shift" }, "Space", oxwm.client.toggle_floating())
196
197
-- Layout management
198
oxwm.key.bind({ modkey }, "F", oxwm.layout.set("normie"))
199
oxwm.key.bind({ modkey }, "C", oxwm.layout.set("tiling"))
200
-- Cycle through layouts
201
oxwm.key.bind({ modkey }, "N", oxwm.layout.cycle())
202
203
-- Master area controls (tiling layout)
204
205
-- Decrease/Increase master area width
206
oxwm.key.bind({ modkey }, "H", oxwm.set_master_factor(-5))
207
oxwm.key.bind({ modkey }, "L", oxwm.set_master_factor(5))
208
-- Increment/Decrement number of master windows
209
oxwm.key.bind({ modkey }, "I", oxwm.inc_num_master(1))
210
oxwm.key.bind({ modkey }, "P", oxwm.inc_num_master(-1))
211
212
-- Gaps toggle
213
oxwm.key.bind({ modkey }, "A", oxwm.toggle_gaps())
214
215
-- Window manager controls
216
oxwm.key.bind({ modkey, "Shift" }, "Q", oxwm.quit())
217
oxwm.key.bind({ modkey, "Shift" }, "R", oxwm.restart())
218
219
-- Focus movement [1 for up in the stack, -1 for down]
220
oxwm.key.bind({ modkey }, "J", oxwm.client.focus_stack(1))
221
oxwm.key.bind({ modkey }, "K", oxwm.client.focus_stack(-1))
222
223
-- Window movement (swap position in stack)
224
oxwm.key.bind({ modkey, "Shift" }, "J", oxwm.client.move_stack(1))
225
oxwm.key.bind({ modkey, "Shift" }, "K", oxwm.client.move_stack(-1))
226
227
-- Multi-monitor support
228
229
-- Focus next/previous Monitors
230
oxwm.key.bind({ modkey }, "Comma", oxwm.monitor.focus(-1))
231
oxwm.key.bind({ modkey }, "Period", oxwm.monitor.focus(1))
232
-- Move window to next/previous Monitors
233
oxwm.key.bind({ modkey, "Shift" }, "Comma", oxwm.monitor.tag(-1))
234
oxwm.key.bind({ modkey, "Shift" }, "Period", oxwm.monitor.tag(1))
235
236
-- Workspace (tag) navigation
237
-- Switch to workspace N (tags are 0-indexed, so tag "1" is index 0)
238
oxwm.key.bind({ modkey }, "1", oxwm.tag.view(0))
239
oxwm.key.bind({ modkey }, "2", oxwm.tag.view(1))
240
oxwm.key.bind({ modkey }, "3", oxwm.tag.view(2))
241
oxwm.key.bind({ modkey }, "4", oxwm.tag.view(3))
242
oxwm.key.bind({ modkey }, "5", oxwm.tag.view(4))
243
oxwm.key.bind({ modkey }, "6", oxwm.tag.view(5))
244
oxwm.key.bind({ modkey }, "7", oxwm.tag.view(6))
245
oxwm.key.bind({ modkey }, "8", oxwm.tag.view(7))
246
oxwm.key.bind({ modkey }, "9", oxwm.tag.view(8))
247
248
-- Move focused window to workspace N
249
oxwm.key.bind({ modkey, "Shift" }, "1", oxwm.tag.move_to(0))
250
oxwm.key.bind({ modkey, "Shift" }, "2", oxwm.tag.move_to(1))
251
oxwm.key.bind({ modkey, "Shift" }, "3", oxwm.tag.move_to(2))
252
oxwm.key.bind({ modkey, "Shift" }, "4", oxwm.tag.move_to(3))
253
oxwm.key.bind({ modkey, "Shift" }, "5", oxwm.tag.move_to(4))
254
oxwm.key.bind({ modkey, "Shift" }, "6", oxwm.tag.move_to(5))
255
oxwm.key.bind({ modkey, "Shift" }, "7", oxwm.tag.move_to(6))
256
oxwm.key.bind({ modkey, "Shift" }, "8", oxwm.tag.move_to(7))
257
oxwm.key.bind({ modkey, "Shift" }, "9", oxwm.tag.move_to(8))
258
259
-- Combo view (view multiple tags at once) {argos_nothing}
260
-- Example: Mod+Ctrl+2 while on tag 1 will show BOTH tags 1 and 2
261
oxwm.key.bind({ modkey, "Control" }, "1", oxwm.tag.toggleview(0))
262
oxwm.key.bind({ modkey, "Control" }, "2", oxwm.tag.toggleview(1))
263
oxwm.key.bind({ modkey, "Control" }, "3", oxwm.tag.toggleview(2))
264
oxwm.key.bind({ modkey, "Control" }, "4", oxwm.tag.toggleview(3))
265
oxwm.key.bind({ modkey, "Control" }, "5", oxwm.tag.toggleview(4))
266
oxwm.key.bind({ modkey, "Control" }, "6", oxwm.tag.toggleview(5))
267
oxwm.key.bind({ modkey, "Control" }, "7", oxwm.tag.toggleview(6))
268
oxwm.key.bind({ modkey, "Control" }, "8", oxwm.tag.toggleview(7))
269
oxwm.key.bind({ modkey, "Control" }, "9", oxwm.tag.toggleview(8))
270
271
-- Multi tag (window on multiple tags)
272
-- Example: Mod+Ctrl+Shift+2 puts focused window on BOTH current tag and tag 2
273
oxwm.key.bind({ modkey, "Control", "Shift" }, "1", oxwm.tag.toggletag(0))
274
oxwm.key.bind({ modkey, "Control", "Shift" }, "2", oxwm.tag.toggletag(1))
275
oxwm.key.bind({ modkey, "Control", "Shift" }, "3", oxwm.tag.toggletag(2))
276
oxwm.key.bind({ modkey, "Control", "Shift" }, "4", oxwm.tag.toggletag(3))
277
oxwm.key.bind({ modkey, "Control", "Shift" }, "5", oxwm.tag.toggletag(4))
278
oxwm.key.bind({ modkey, "Control", "Shift" }, "6", oxwm.tag.toggletag(5))
279
oxwm.key.bind({ modkey, "Control", "Shift" }, "7", oxwm.tag.toggletag(6))
280
oxwm.key.bind({ modkey, "Control", "Shift" }, "8", oxwm.tag.toggletag(7))
281
oxwm.key.bind({ modkey, "Control", "Shift" }, "9", oxwm.tag.toggletag(8))
282
283
-------------------------------------------------------------------------------
284
-- Advanced: Keychords
285
-------------------------------------------------------------------------------
286
-- Keychords allow you to bind multiple-key sequences (like Emacs or Vim)
287
-- Format: {{modifiers}, key1}, {{modifiers}, key2}, ...
288
-- Example: Press Mod4+Space, then release and press T to spawn a terminal
289
oxwm.key.chord({
290
    { { modkey }, "Space" },
291
    { {},         "T" }
292
}, oxwm.spawn_terminal())
293
294
-------------------------------------------------------------------------------
295
-- Autostart
296
-------------------------------------------------------------------------------
297
-- Commands to run once when OXWM starts
298
-- Uncomment and modify these examples, or add your own
299
300
-- oxwm.autostart("picom")                                  
301
-- oxwm.autostart("feh --bg-scale ~/wallpaper.jpg") 
302
-- oxwm.autostart("dunst")
303
-- oxwm.autostart("nm-applet")