oxwm

https://git.tonybtw.com/oxwm.git git://git.tonybtw.com/oxwm.git
12,724 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
local colors = {
29
    fg = "#bbbbbb",
30
    red = "#f7768e",
31
    bg = "#1a1b26",
32
    cyan = "#0db9d7",
33
    green = "#9ece6a",
34
    lavender = "#a9b1d6",
35
    light_blue = "#7aa2f7",
36
    grey = "#bbbbbb",
37
    blue = "#6dade3",
38
    purple = "#ad8ee6",
39
}
40
41
-- Workspace tags - can be numbers, names, or icons (requires a Nerd Font)
42
local tags = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }
43
-- local tags = { "", "󰊯", "", "", "󰙯", "󱇤", "", "󱘶", "󰧮" } -- Example of nerd font icon tags
44
45
-- Font for the status bar (use "fc-list" to see available fonts)
46
local bar_font = "monospace:style=Bold:size=10"
47
48
-- Define your blocks
49
-- Similar to widgets in qtile, or dwmblocks
50
local blocks = {
51
    oxwm.bar.block.ram({
52
        format = "Ram: {used}/{total} GB",
53
        interval = 5,
54
        color = colors.light_blue,
55
        underline = true,
56
    }),
57
    oxwm.bar.block.static({
58
        format = "{}",
59
        text = " │  ",
60
        interval = 999999999,
61
        color = colors.lavender,
62
        underline = false,
63
    }),
64
    oxwm.bar.block.shell({
65
        format = "Kernel: {}",
66
        command = "uname -r",
67
        interval = 999999999,
68
        color = colors.red,
69
        underline = true,
70
    }),
71
    oxwm.bar.block.static({
72
        format = "{}",
73
        text = " │  ",
74
        interval = 999999999,
75
        color = colors.lavender,
76
        underline = false,
77
    }),
78
    oxwm.bar.block.datetime({
79
        format = "{}",
80
        date_format = "%a, %b %d - %-I:%M %P",
81
        interval = 1,
82
        color = colors.cyan,
83
        underline = true,
84
    }),
85
    -- Uncomment to add battery status (useful for laptops)
86
    -- oxwm.bar.block.battery({
87
    --     format = "Bat: {}%",
88
    --     charging = "⚡ Bat: {}%",
89
    --     discharging = "- Bat: {}%",
90
    --     full = "✓ Bat: {}%",
91
    --     interval = 30,
92
    --     color = colors.green,
93
    --     underline = true,
94
    -- }),
95
};
96
97
-------------------------------------------------------------------------------
98
-- Basic Settings
99
-------------------------------------------------------------------------------
100
oxwm.set_terminal(terminal)
101
oxwm.set_modkey(modkey) -- This is for Mod + mouse binds, such as drag/resize
102
oxwm.set_tags(tags)
103
104
-------------------------------------------------------------------------------
105
-- Layouts
106
-------------------------------------------------------------------------------
107
-- Set custom symbols for layouts (displayed in the status bar)
108
-- Available layouts: "tiling", "normie" (floating), "grid", "monocle", "tabbed"
109
oxwm.set_layout_symbol("tiling", "[T]")
110
oxwm.set_layout_symbol("normie", "[F]")
111
oxwm.set_layout_symbol("tabbed", "[=]")
112
113
-------------------------------------------------------------------------------
114
-- Appearance
115
-------------------------------------------------------------------------------
116
-- Border configuration
117
oxwm.border.set_width(2)                     -- Width in pixels
118
oxwm.border.set_focused_color(colors.blue)   -- Color of focused window border
119
oxwm.border.set_unfocused_color(colors.grey) -- Color of unfocused window borders
120
121
-- Gap configuration (space between windows and screen edges)
122
oxwm.gaps.set_enabled(true) -- Enable or disable gaps
123
oxwm.gaps.set_inner(5, 5)   -- Inner gaps (horizontal, vertical) in pixels
124
oxwm.gaps.set_outer(5, 5)   -- Outer gaps (horizontal, vertical) in pixels
125
126
-------------------------------------------------------------------------------
127
-- Status Bar Configuration
128
-------------------------------------------------------------------------------
129
-- Font configuration
130
oxwm.bar.set_font(bar_font)
131
132
-- Set your blocks here (defined above)
133
oxwm.bar.set_blocks(blocks)
134
135
-- Bar color schemes (for workspace tag display)
136
-- Parameters: foreground, background, border
137
oxwm.bar.set_scheme_normal(colors.fg, colors.bg, "#444444")         -- Unoccupied tags
138
oxwm.bar.set_scheme_occupied(colors.cyan, colors.bg, colors.cyan)   -- Occupied tags
139
oxwm.bar.set_scheme_selected(colors.cyan, colors.bg, colors.purple) -- Currently selected tag
140
141
-------------------------------------------------------------------------------
142
-- Keybindings
143
-------------------------------------------------------------------------------
144
-- Keybindings are defined using oxwm.key.bind(modifiers, key, action)
145
-- Modifiers: {"Mod4"}, {"Mod1"}, {"Shift"}, {"Control"}, or combinations like {"Mod4", "Shift"}
146
-- Keys: Use uppercase for letters (e.g., "Return", "H", "J", "K", "L")
147
-- Actions: Functions that return actions (e.g., oxwm.spawn(), oxwm.client.kill())
148
--
149
-- A list of available keysyms can be found in the X11 keysym definitions.
150
-- Common keys: Return, Space, Tab, Escape, Backspace, Delete, Left, Right, Up, Down
151
152
-- Basic window management
153
oxwm.key.bind({ modkey }, "Return", oxwm.spawn_terminal())                                                      -- Spawn terminal
154
oxwm.key.bind({ modkey }, "D", oxwm.spawn({ "sh", "-c", "dmenu_run -l 10" }))                                   -- Application launcher
155
oxwm.key.bind({ modkey }, "S", oxwm.spawn({ "sh", "-c", "maim -s | xclip -selection clipboard -t image/png" })) -- Screenshot selection
156
oxwm.key.bind({ modkey }, "Q", oxwm.client.kill())                                                              -- Close focused window
157
158
-- Keybind overlay - Shows important keybindings on screen
159
oxwm.key.bind({ modkey, "Shift" }, "Slash", oxwm.show_keybinds())
160
161
-- Window state toggles
162
oxwm.key.bind({ modkey, "Shift" }, "F", oxwm.client.toggle_fullscreen())   -- Toggle fullscreen
163
oxwm.key.bind({ modkey, "Shift" }, "Space", oxwm.client.toggle_floating()) -- Toggle floating mode
164
165
-- Layout management
166
oxwm.key.bind({ modkey }, "F", oxwm.layout.set("normie")) -- Set floating layout
167
oxwm.key.bind({ modkey }, "C", oxwm.layout.set("tiling")) -- Set tiling layout
168
oxwm.key.bind({ modkey }, "N", oxwm.layout.cycle())       -- Cycle through layouts
169
170
-- Gaps toggle
171
oxwm.key.bind({ modkey }, "A", oxwm.toggle_gaps()) -- Toggle gaps on/off
172
173
-- Window manager controls
174
oxwm.key.bind({ modkey, "Shift" }, "Q", oxwm.quit())    -- Quit OXWM
175
oxwm.key.bind({ modkey, "Shift" }, "R", oxwm.restart()) -- Restart OXWM (reloads config)
176
177
-- Focus movement (vim keys)
178
oxwm.key.bind({ modkey }, "H", oxwm.client.focus_direction("left"))  -- Focus window to the left
179
oxwm.key.bind({ modkey }, "J", oxwm.client.focus_direction("down"))  -- Focus window below
180
oxwm.key.bind({ modkey }, "K", oxwm.client.focus_direction("up"))    -- Focus window above
181
oxwm.key.bind({ modkey }, "L", oxwm.client.focus_direction("right")) -- Focus window to the right
182
183
-- Multi-monitor support
184
oxwm.key.bind({ modkey }, "Comma", oxwm.focus_monitor(-1)) -- Focus previous monitor
185
oxwm.key.bind({ modkey }, "Period", oxwm.focus_monitor(1)) -- Focus next monitor
186
187
-- Workspace (tag) navigation
188
-- Switch to workspace N (tags are 0-indexed, so tag "1" is index 0)
189
oxwm.key.bind({ modkey }, "1", oxwm.tag.view(0))
190
oxwm.key.bind({ modkey }, "2", oxwm.tag.view(1))
191
oxwm.key.bind({ modkey }, "3", oxwm.tag.view(2))
192
oxwm.key.bind({ modkey }, "4", oxwm.tag.view(3))
193
oxwm.key.bind({ modkey }, "5", oxwm.tag.view(4))
194
oxwm.key.bind({ modkey }, "6", oxwm.tag.view(5))
195
oxwm.key.bind({ modkey }, "7", oxwm.tag.view(6))
196
oxwm.key.bind({ modkey }, "8", oxwm.tag.view(7))
197
oxwm.key.bind({ modkey }, "9", oxwm.tag.view(8))
198
199
-- Move focused window to workspace N
200
oxwm.key.bind({ modkey, "Shift" }, "1", oxwm.tag.move_to(0))
201
oxwm.key.bind({ modkey, "Shift" }, "2", oxwm.tag.move_to(1))
202
oxwm.key.bind({ modkey, "Shift" }, "3", oxwm.tag.move_to(2))
203
oxwm.key.bind({ modkey, "Shift" }, "4", oxwm.tag.move_to(3))
204
oxwm.key.bind({ modkey, "Shift" }, "5", oxwm.tag.move_to(4))
205
oxwm.key.bind({ modkey, "Shift" }, "6", oxwm.tag.move_to(5))
206
oxwm.key.bind({ modkey, "Shift" }, "7", oxwm.tag.move_to(6))
207
oxwm.key.bind({ modkey, "Shift" }, "8", oxwm.tag.move_to(7))
208
oxwm.key.bind({ modkey, "Shift" }, "9", oxwm.tag.move_to(8))
209
210
-- Swap windows in direction (vim keys with Shift)
211
oxwm.key.bind({ modkey, "Shift" }, "H", oxwm.client.swap_direction("left"))  -- Swap with window to the left
212
oxwm.key.bind({ modkey, "Shift" }, "J", oxwm.client.swap_direction("down"))  -- Swap with window below
213
oxwm.key.bind({ modkey, "Shift" }, "K", oxwm.client.swap_direction("up"))    -- Swap with window above
214
oxwm.key.bind({ modkey, "Shift" }, "L", oxwm.client.swap_direction("right")) -- Swap with window to the right
215
216
-------------------------------------------------------------------------------
217
-- Advanced: Keychords
218
-------------------------------------------------------------------------------
219
-- Keychords allow you to bind multiple-key sequences (like Emacs or Vim)
220
-- Format: {{modifiers}, key1}, {{modifiers}, key2}, ...
221
-- Example: Press Mod4+Space, then release and press T to spawn a terminal
222
oxwm.key.chord({
223
    { { modkey }, "Space" },
224
    { {},         "T" }
225
}, oxwm.spawn_terminal())
226
227
-------------------------------------------------------------------------------
228
-- Status Bar Blocks
229
-------------------------------------------------------------------------------
230
-- Add informational blocks to the status bar using block constructors
231
-- Each block is created with oxwm.bar.block.<type>() and configured with a table:
232
--   format: Display format with {} placeholders
233
--   interval: Seconds between updates
234
--   color: Text color (from color palette)
235
--   underline: Whether to underline the block
236
--
237
-- Available block types:
238
--   ram(config)         - Memory usage
239
--   datetime(config)    - Date and time (requires date_format field)
240
--   shell(config)       - Shell command output (requires command field)
241
--   static(config)      - Static text (requires text field)
242
--   battery(config)     - Battery status (requires charging, discharging, full fields)
243
244
oxwm.bar.set_blocks({
245
    oxwm.bar.block.ram({
246
        format = "Ram: {used}/{total} GB",
247
        interval = 5,
248
        color = colors.light_blue,
249
        underline = true,
250
    }),
251
    oxwm.bar.block.static({
252
        format = "{}",
253
        text = " │  ",
254
        interval = 999999999,
255
        color = colors.lavender,
256
        underline = false,
257
    }),
258
    oxwm.bar.block.shell({
259
        format = "Kernel: {}",
260
        command = "uname -r",
261
        interval = 999999999,
262
        color = colors.red,
263
        underline = true,
264
    }),
265
    oxwm.bar.block.static({
266
        format = "{}",
267
        text = " │  ",
268
        interval = 999999999,
269
        color = colors.lavender,
270
        underline = false,
271
    }),
272
    oxwm.bar.block.datetime({
273
        format = "{}",
274
        date_format = "%a, %b %d - %-I:%M %P",
275
        interval = 1,
276
        color = colors.cyan,
277
        underline = true,
278
    }),
279
    -- Uncomment to add battery status (useful for laptops)
280
    -- oxwm.bar.block.battery({
281
    --     format = "Bat: {}%",
282
    --     charging = "⚡ Bat: {}%",
283
    --     discharging = "🔋 Bat: {}%",
284
    --     full = "✓ Bat: {}%",
285
    --     interval = 30,
286
    --     color = colors.green,
287
    --     underline = true,
288
    -- }),
289
})
290
291
-------------------------------------------------------------------------------
292
-- Autostart
293
-------------------------------------------------------------------------------
294
-- Commands to run once when OXWM starts
295
-- Uncomment and modify these examples, or add your own
296
297
-- oxwm.autostart("picom")                                  -- Compositor for transparency and effects
298
-- oxwm.autostart("feh --bg-scale ~/wallpaper.jpg")        -- Set wallpaper
299
-- oxwm.autostart("dunst")                                  -- Notification daemon
300
-- oxwm.autostart("nm-applet")                              -- Network manager applet