oxwm

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