tony / oxwm

Updated oxwm.lua with move_win(), updated default config.lua file with better comments. removed logic to create lib directory with in ~/.config/oxwm to not confuse users. Browse files
tonybtw committed 2025-12-03 parent df1e570 commit 08f9ddfcfe380d0c6ff2b04d5bf0a4de3defd20f
Showing 3 changed files with 94 additions and 92 deletions. UnifiedSplit
+0 −46 src/bin/main.rs
@@ -101,59 +101,13 @@ fn init_config() -> Result<(), Box<dyn std::error::Error>> {
101 let config_path = config_directory.join("config.lua"); 101 let config_path = config_directory.join("config.lua");
102 std::fs::write(&config_path, config_template)?; 102 std::fs::write(&config_path, config_template)?;
103 103
104 - update_lsp_files()?;
105 -
106 println!("✓ Config created at {:?}", config_path); 104 println!("✓ Config created at {:?}", config_path);
107 - println!("✓ LSP definitions installed at {:?}/lib/oxwm.lua", config_directory);
108 println!(" Edit the file and reload with Mod+Shift+R"); 105 println!(" Edit the file and reload with Mod+Shift+R");
109 println!(" No compilation needed - changes take effect immediately!"); 106 println!(" No compilation needed - changes take effect immediately!");
110 107
111 Ok(()) 108 Ok(())
112 } 109 }
113 110
114 -fn update_lsp_files() -> Result<(), Box<dyn std::error::Error>> {
115 - let config_directory = get_config_path();
116 -
117 - let system_paths = [
118 - PathBuf::from("/usr/share/oxwm/oxwm.lua"),
119 - PathBuf::from("/usr/local/share/oxwm/oxwm.lua"),
120 - ];
121 -
122 - let system_oxwm_lua = system_paths.iter().find(|path| path.exists());
123 -
124 - let luarc_content = if let Some(system_path) = system_oxwm_lua {
125 - format!(
126 - r#"{{
127 - "workspace.library": [
128 - "{}"
129 - ]
130 -}}
131 -"#,
132 - system_path.parent().unwrap().display()
133 - )
134 - } else {
135 - let library_directory = config_directory.join("lib");
136 - std::fs::create_dir_all(&library_directory)?;
137 -
138 - let oxwm_lua_template = include_str!("../../templates/oxwm.lua");
139 - let oxwm_lua_path = library_directory.join("oxwm.lua");
140 - std::fs::write(&oxwm_lua_path, oxwm_lua_template)?;
141 -
142 - r#"{
143 - "workspace.library": [
144 - "lib"
145 - ]
146 -}
147 -"#
148 - .to_string()
149 - };
150 -
151 - let luarc_path = config_directory.join(".luarc.json");
152 - std::fs::write(&luarc_path, luarc_content)?;
153 -
154 - Ok(())
155 -}
156 -
157 fn get_config_path() -> PathBuf { 111 fn get_config_path() -> PathBuf {
158 dirs::config_dir() 112 dirs::config_dir()
159 .expect("Could not find config directory") 113 .expect("Could not find config directory")
+89 −46 templates/config.lua
@@ -25,6 +25,9 @@ local modkey = "Mod4"
25 local terminal = "alacritty" 25 local terminal = "alacritty"
26 26
27 -- Color palette - customize these to match your theme 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
28 local colors = { 31 local colors = {
29 fg = "#bbbbbb", 32 fg = "#bbbbbb",
30 red = "#f7768e", 33 red = "#f7768e",
@@ -55,28 +58,24 @@ local blocks = {
55 underline = true, 58 underline = true,
56 }), 59 }),
57 oxwm.bar.block.static({ 60 oxwm.bar.block.static({
58 - format = "{}",
59 text = " │ ", 61 text = " │ ",
60 interval = 999999999, 62 interval = 999999999,
61 color = colors.lavender, 63 color = colors.lavender,
62 underline = false, 64 underline = false,
63 }), 65 }),
64 oxwm.bar.block.shell({ 66 oxwm.bar.block.shell({
65 - format = "Kernel: {}",
66 command = "uname -r", 67 command = "uname -r",
67 interval = 999999999, 68 interval = 999999999,
68 color = colors.red, 69 color = colors.red,
69 underline = true, 70 underline = true,
70 }), 71 }),
71 oxwm.bar.block.static({ 72 oxwm.bar.block.static({
72 - format = "{}",
73 text = " │ ", 73 text = " │ ",
74 interval = 999999999, 74 interval = 999999999,
75 color = colors.lavender, 75 color = colors.lavender,
76 underline = false, 76 underline = false,
77 }), 77 }),
78 oxwm.bar.block.datetime({ 78 oxwm.bar.block.datetime({
79 - format = "{}",
80 date_format = "%a, %b %d - %-I:%M %P", 79 date_format = "%a, %b %d - %-I:%M %P",
81 interval = 1, 80 interval = 1,
82 color = colors.cyan, 81 color = colors.cyan,
@@ -114,14 +113,20 @@ oxwm.set_layout_symbol("tabbed", "[=]")
114 -- Appearance 113 -- Appearance
115 ------------------------------------------------------------------------------- 114 -------------------------------------------------------------------------------
116 -- Border configuration 115 -- 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 116
121 --- Gap configuration (space between windows and screen edges) 117 +-- Width in pixels
122 -oxwm.gaps.set_enabled(true) -- Enable or disable gaps 118 +oxwm.border.set_width(2)
123 -oxwm.gaps.set_inner(5, 5) -- Inner gaps (horizontal, vertical) in pixels 119 +-- Color of focused window border
124 -oxwm.gaps.set_outer(5, 5) -- Outer gaps (horizontal, vertical) in pixels 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)
125 130
126 ------------------------------------------------------------------------------- 131 -------------------------------------------------------------------------------
127 -- Window Rules 132 -- Window Rules
@@ -136,9 +141,9 @@ oxwm.gaps.set_outer(5, 5) -- Outer gaps (horizontal, vertical) in pixels
136 -- - Configure window behavior based on title or class 141 -- - Configure window behavior based on title or class
137 142
138 -- Examples (uncomment to use): 143 -- Examples (uncomment to use):
139 --- oxwm.rule.add({ class = "firefox", title = "Library", floating = true }) -- Make Firefox Library window floating 144 +oxwm.rule.add({ instance = "gimp", floating = true })
140 --- oxwm.rule.add({ instance = "gimp", tag = 5 }) -- Send GIMP to workspace 6 (0-indexed) 145 +-- oxwm.rule.add({ class = "firefox", title = "Library", floating = true })
141 --- oxwm.rule.add({ instance = "mpv", floating = true }) -- Make mpv always float 146 +-- oxwm.rule.add({ instance = "mpv", floating = true })
142 147
143 -- To find window properties, use xprop and click on the window 148 -- To find window properties, use xprop and click on the window
144 -- WM_CLASS(STRING) shows both instance and class (instance, class) 149 -- WM_CLASS(STRING) shows both instance and class (instance, class)
@@ -154,9 +159,13 @@ oxwm.bar.set_blocks(blocks)
154 159
155 -- Bar color schemes (for workspace tag display) 160 -- Bar color schemes (for workspace tag display)
156 -- Parameters: foreground, background, border 161 -- Parameters: foreground, background, border
157 -oxwm.bar.set_scheme_normal(colors.fg, colors.bg, "#444444") -- Unoccupied tags 162 +
158 -oxwm.bar.set_scheme_occupied(colors.cyan, colors.bg, colors.cyan) -- Occupied tags 163 +-- Unoccupied tags
159 -oxwm.bar.set_scheme_selected(colors.cyan, colors.bg, colors.purple) -- Currently selected tag 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)
160 169
161 ------------------------------------------------------------------------------- 170 -------------------------------------------------------------------------------
162 -- Keybindings 171 -- Keybindings
@@ -170,49 +179,59 @@ oxwm.bar.set_scheme_selected(colors.cyan, colors.bg, colors.purple) -- Currently
170 -- Common keys: Return, Space, Tab, Escape, Backspace, Delete, Left, Right, Up, Down 179 -- Common keys: Return, Space, Tab, Escape, Backspace, Delete, Left, Right, Up, Down
171 180
172 -- Basic window management 181 -- Basic window management
173 -oxwm.key.bind({ modkey }, "Return", oxwm.spawn_terminal()) -- Spawn terminal 182 +
174 -oxwm.key.bind({ modkey }, "D", oxwm.spawn({ "sh", "-c", "dmenu_run -l 10" })) -- Application launcher 183 +oxwm.key.bind({ modkey }, "Return", oxwm.spawn_terminal())
175 -oxwm.key.bind({ modkey }, "S", oxwm.spawn({ "sh", "-c", "maim -s | xclip -selection clipboard -t image/png" })) -- Screenshot selection 184 +-- Launch Dmenu
176 -oxwm.key.bind({ modkey }, "Q", oxwm.client.kill()) -- Close focused window 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())
177 189
178 -- Keybind overlay - Shows important keybindings on screen 190 -- Keybind overlay - Shows important keybindings on screen
179 oxwm.key.bind({ modkey, "Shift" }, "Slash", oxwm.show_keybinds()) 191 oxwm.key.bind({ modkey, "Shift" }, "Slash", oxwm.show_keybinds())
180 192
181 -- Window state toggles 193 -- Window state toggles
182 -oxwm.key.bind({ modkey, "Shift" }, "F", oxwm.client.toggle_fullscreen()) -- Toggle fullscreen 194 +oxwm.key.bind({ modkey, "Shift" }, "F", oxwm.client.toggle_fullscreen())
183 -oxwm.key.bind({ modkey, "Shift" }, "Space", oxwm.client.toggle_floating()) -- Toggle floating mode 195 +oxwm.key.bind({ modkey, "Shift" }, "Space", oxwm.client.toggle_floating())
184 196
185 -- Layout management 197 -- Layout management
186 -oxwm.key.bind({ modkey }, "F", oxwm.layout.set("normie")) -- Set floating layout 198 +oxwm.key.bind({ modkey }, "F", oxwm.layout.set("normie"))
187 -oxwm.key.bind({ modkey }, "C", oxwm.layout.set("tiling")) -- Set tiling layout 199 +oxwm.key.bind({ modkey }, "C", oxwm.layout.set("tiling"))
188 -oxwm.key.bind({ modkey }, "N", oxwm.layout.cycle()) -- Cycle through layouts 200 +-- Cycle through layouts
201 +oxwm.key.bind({ modkey }, "N", oxwm.layout.cycle())
189 202
190 -- Master area controls (tiling layout) 203 -- Master area controls (tiling layout)
191 -oxwm.key.bind({ modkey }, "H", oxwm.set_master_factor(-5)) -- Decrease master area width 204 +
192 -oxwm.key.bind({ modkey }, "L", oxwm.set_master_factor(5)) -- Increase master area width 205 +-- Decrease/Increase master area width
193 -oxwm.key.bind({ modkey }, "I", oxwm.inc_num_master(1)) -- Increment number of master windows 206 +oxwm.key.bind({ modkey }, "H", oxwm.set_master_factor(-5))
194 -oxwm.key.bind({ modkey }, "P", oxwm.inc_num_master(-1)) -- Decrement number of master windows 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))
195 211
196 -- Gaps toggle 212 -- Gaps toggle
197 -oxwm.key.bind({ modkey }, "A", oxwm.toggle_gaps()) -- Toggle gaps on/off 213 +oxwm.key.bind({ modkey }, "A", oxwm.toggle_gaps())
198 214
199 -- Window manager controls 215 -- Window manager controls
200 -oxwm.key.bind({ modkey, "Shift" }, "Q", oxwm.quit()) -- Quit OXWM 216 +oxwm.key.bind({ modkey, "Shift" }, "Q", oxwm.quit())
201 -oxwm.key.bind({ modkey, "Shift" }, "R", oxwm.restart()) -- Restart OXWM (reloads config) 217 +oxwm.key.bind({ modkey, "Shift" }, "R", oxwm.restart())
202 218
203 --- Focus movement (stack cycling) 219 +-- Focus movement [1 for up in the stack, -1 for down]
204 -oxwm.key.bind({ modkey }, "J", oxwm.client.focus_stack(1)) -- Focus next window in stack 220 +oxwm.key.bind({ modkey }, "J", oxwm.client.focus_stack(1))
205 -oxwm.key.bind({ modkey }, "K", oxwm.client.focus_stack(-1)) -- Focus previous window in stack 221 +oxwm.key.bind({ modkey }, "K", oxwm.client.focus_stack(-1))
206 222
207 -- Window movement (swap position in stack) 223 -- Window movement (swap position in stack)
208 -oxwm.key.bind({ modkey, "Shift" }, "J", oxwm.client.move_stack(1)) -- Move window down in stack 224 +oxwm.key.bind({ modkey, "Shift" }, "J", oxwm.client.move_stack(1))
209 -oxwm.key.bind({ modkey, "Shift" }, "K", oxwm.client.move_stack(-1)) -- Move window up in stack 225 +oxwm.key.bind({ modkey, "Shift" }, "K", oxwm.client.move_stack(-1))
210 226
211 -- Multi-monitor support 227 -- Multi-monitor support
212 -oxwm.key.bind({ modkey }, "Comma", oxwm.monitor.focus(-1)) -- Focus previous monitor 228 +
213 -oxwm.key.bind({ modkey }, "Period", oxwm.monitor.focus(1)) -- Focus next monitor 229 +-- Focus next/previous Monitors
214 -oxwm.key.bind({ modkey, "Shift" }, "Comma", oxwm.monitor.tag(-1)) -- Send window to previous monitor 230 +oxwm.key.bind({ modkey }, "Comma", oxwm.monitor.focus(-1))
215 -oxwm.key.bind({ modkey, "Shift" }, "Period", oxwm.monitor.tag(1)) -- Send window to next monitor 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))
216 235
217 -- Workspace (tag) navigation 236 -- Workspace (tag) navigation
218 -- Switch to workspace N (tags are 0-indexed, so tag "1" is index 0) 237 -- Switch to workspace N (tags are 0-indexed, so tag "1" is index 0)
@@ -237,6 +256,30 @@ oxwm.key.bind({ modkey, "Shift" }, "7", oxwm.tag.move_to(6))
237 oxwm.key.bind({ modkey, "Shift" }, "8", oxwm.tag.move_to(7)) 256 oxwm.key.bind({ modkey, "Shift" }, "8", oxwm.tag.move_to(7))
238 oxwm.key.bind({ modkey, "Shift" }, "9", oxwm.tag.move_to(8)) 257 oxwm.key.bind({ modkey, "Shift" }, "9", oxwm.tag.move_to(8))
239 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 +
240 ------------------------------------------------------------------------------- 283 -------------------------------------------------------------------------------
241 -- Advanced: Keychords 284 -- Advanced: Keychords
242 ------------------------------------------------------------------------------- 285 -------------------------------------------------------------------------------
@@ -254,7 +297,7 @@ oxwm.key.chord({
254 -- Commands to run once when OXWM starts 297 -- Commands to run once when OXWM starts
255 -- Uncomment and modify these examples, or add your own 298 -- Uncomment and modify these examples, or add your own
256 299
257 --- oxwm.autostart("picom") -- Compositor for transparency and effects 300 +-- oxwm.autostart("picom")
258 --- oxwm.autostart("feh --bg-scale ~/wallpaper.jpg") -- Set wallpaper 301 +-- oxwm.autostart("feh --bg-scale ~/wallpaper.jpg")
259 --- oxwm.autostart("dunst") -- Notification daemon 302 +-- oxwm.autostart("dunst")
260 --- oxwm.autostart("nm-applet") -- Network manager applet 303 +-- oxwm.autostart("nm-applet")
+5 −0 templates/oxwm.lua
@@ -160,6 +160,11 @@ function oxwm.client.toggle_floating() end
160 ---@return table Action table for keybinding 160 ---@return table Action table for keybinding
161 function oxwm.client.focus_stack(dir) end 161 function oxwm.client.focus_stack(dir) end
162 162
163 +---Move stack (next/previous window)
164 +---@param dir integer Direction (1 for next, -1 for previous)
165 +---@return table Action table for keybinding
166 +function oxwm.client.move_stack(dir) end
167 +
163 ---Monitor management module 168 ---Monitor management module
164 ---@class oxwm.monitor 169 ---@class oxwm.monitor
165 oxwm.monitor = {} 170 oxwm.monitor = {}