tony / oxwm

Changed defaults Browse files
tonybtw committed 2025-10-11 parent 15bb7a7 commit 4f158bef2d99ab380fb4cffb6326154265b56ca0
Showing 3 changed files with 227 additions and 29 deletions. UnifiedSplit
+190 −0 src/config.rs.backup new file mode 100644
@@ -0,0 +1,190 @@
1 +use crate::bar::{BlockCommand, BlockConfig};
2 +use crate::keyboard::handlers::Key;
3 +use crate::keyboard::{Arg, KeyAction, keycodes};
4 +use x11rb::protocol::xproto::KeyButMask;
5 +
6 +// ========================================
7 +// APPEARANCE
8 +// ========================================
9 +pub const BORDER_WIDTH: u32 = 2;
10 +pub const BORDER_FOCUSED: u32 = 0x6dade3;
11 +pub const BORDER_UNFOCUSED: u32 = 0xbbbbbb;
12 +pub const FONT: &str = "JetBrainsMono Nerd Font:style=Bold:size=12";
13 +
14 +// ========================================
15 +// GAPS (Vanity Gaps)
16 +// ========================================
17 +pub const GAPS_ENABLED: bool = false;
18 +pub const GAP_INNER_HORIZONTAL: u32 = 3;
19 +pub const GAP_INNER_VERTICAL: u32 = 3;
20 +pub const GAP_OUTER_HORIZONTAL: u32 = 3;
21 +pub const GAP_OUTER_VERTICAL: u32 = 3;
22 +//
23 +// ========================================
24 +// DEFAULTS
25 +// ========================================
26 +pub const TERMINAL: &str = "st";
27 +pub const XCLOCK: &str = "xclock";
28 +pub const MODKEY: KeyButMask = KeyButMask::MOD4;
29 +
30 +// ========================================
31 +// BAR COLORS
32 +// ========================================
33 +
34 +// Base colors
35 +const GRAY_DARK: u32 = 0x1a1b26;
36 +const GRAY_SEP: u32 = 0xa9b1d6;
37 +const GRAY_MID: u32 = 0x444444;
38 +const GRAY_LIGHT: u32 = 0xbbbbbb;
39 +const CYAN: u32 = 0x0db9d7;
40 +const MAGENTA: u32 = 0xad8ee6;
41 +const RED: u32 = 0xf7768e;
42 +const GREEN: u32 = 0x9ece6a;
43 +const BLUE: u32 = 0x7aa2f7;
44 +const YELLOW: u32 = 0xe0af68;
45 +
46 +pub struct ColorScheme {
47 + pub foreground: u32,
48 + pub background: u32,
49 + pub underline: u32,
50 +}
51 +
52 +pub const SCHEME_NORMAL: ColorScheme = ColorScheme {
53 + foreground: GRAY_LIGHT,
54 + background: GRAY_DARK,
55 + underline: GRAY_MID,
56 +};
57 +
58 +pub const SCHEME_OCCUPIED: ColorScheme = ColorScheme {
59 + foreground: CYAN,
60 + background: GRAY_DARK,
61 + underline: CYAN,
62 +};
63 +
64 +pub const SCHEME_SELECTED: ColorScheme = ColorScheme {
65 + foreground: CYAN,
66 + background: GRAY_DARK,
67 + underline: MAGENTA,
68 +};
69 +
70 +// ========================================
71 +// Commands
72 +// ========================================
73 +const SCREENSHOT_CMD: &[&str] = &[
74 + "sh",
75 + "-c",
76 + "maim -s | xclip -selection clipboard -t image/png",
77 +];
78 +
79 +const DMENU_CMD: &[&str] = &["sh", "-c", "dmenu_run -l 10"];
80 +
81 +// ========================================
82 +// TAGS
83 +// ========================================
84 +pub const TAG_COUNT: usize = 9;
85 +pub const TAGS: [&str; TAG_COUNT] = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
86 +//pub const TAGS: [&str; TAG_COUNT] = ["", "󰊯", "", "", "󰙯", "󱇤", "", "󱘶", "󰧮"];
87 +// pub const TAGS: [&str; TAG_COUNT] = [
88 +// "DEV", "WWW", "SYS", "DOC", "VBOX", "CHAT", "MUS", "VID", "MISC",
89 +// ];
90 +
91 +// ========================================
92 +// KEYBINDINGS
93 +// ========================================
94 +#[rustfmt::skip]
95 +pub const KEYBINDINGS: &[Key] = &[
96 + Key::new(&[MODKEY], keycodes::RETURN, KeyAction::Spawn, Arg::Str(TERMINAL)),
97 + Key::new(&[MODKEY], keycodes::F, KeyAction::Spawn, Arg::Str(XCLOCK)),
98 +
99 + Key::new(&[MODKEY], keycodes::S, KeyAction::Spawn, Arg::Array(SCREENSHOT_CMD)),
100 + Key::new(&[MODKEY], keycodes::D, KeyAction::Spawn, Arg::Array(DMENU_CMD)),
101 + Key::new(&[MODKEY], keycodes::Q, KeyAction::KillClient, Arg::None),
102 + Key::new(&[MODKEY, SHIFT], keycodes::F, KeyAction::ToggleFullScreen, Arg::None),
103 + Key::new(&[MODKEY], keycodes::A, KeyAction::ToggleGaps, Arg::None),
104 + Key::new(&[MODKEY, SHIFT], keycodes::Q, KeyAction::Quit, Arg::None),
105 + Key::new(&[MODKEY, SHIFT], keycodes::R, KeyAction::Restart, Arg::None),
106 + Key::new(&[MODKEY], keycodes::J, KeyAction::FocusStack, Arg::Int(-1)),
107 + Key::new(&[MODKEY], keycodes::K, KeyAction::FocusStack, Arg::Int(1)),
108 +
109 + Key::new(&[MODKEY], keycodes::KEY_1, KeyAction::ViewTag, Arg::Int(0)),
110 + Key::new(&[MODKEY], keycodes::KEY_2, KeyAction::ViewTag, Arg::Int(1)),
111 + Key::new(&[MODKEY], keycodes::KEY_3, KeyAction::ViewTag, Arg::Int(2)),
112 + Key::new(&[MODKEY], keycodes::KEY_4, KeyAction::ViewTag, Arg::Int(3)),
113 + Key::new(&[MODKEY], keycodes::KEY_5, KeyAction::ViewTag, Arg::Int(4)),
114 + Key::new(&[MODKEY], keycodes::KEY_6, KeyAction::ViewTag, Arg::Int(5)),
115 + Key::new(&[MODKEY], keycodes::KEY_7, KeyAction::ViewTag, Arg::Int(6)),
116 + Key::new(&[MODKEY], keycodes::KEY_8, KeyAction::ViewTag, Arg::Int(7)),
117 + Key::new(&[MODKEY], keycodes::KEY_9, KeyAction::ViewTag, Arg::Int(8)),
118 +
119 + Key::new(&[MODKEY, SHIFT], keycodes::KEY_1, KeyAction::MoveToTag, Arg::Int(0)),
120 + Key::new(&[MODKEY, SHIFT], keycodes::KEY_2, KeyAction::MoveToTag, Arg::Int(1)),
121 + Key::new(&[MODKEY, SHIFT], keycodes::KEY_3, KeyAction::MoveToTag, Arg::Int(2)),
122 + Key::new(&[MODKEY, SHIFT], keycodes::KEY_4, KeyAction::MoveToTag, Arg::Int(3)),
123 + Key::new(&[MODKEY, SHIFT], keycodes::KEY_5, KeyAction::MoveToTag, Arg::Int(4)),
124 + Key::new(&[MODKEY, SHIFT], keycodes::KEY_6, KeyAction::MoveToTag, Arg::Int(5)),
125 + Key::new(&[MODKEY, SHIFT], keycodes::KEY_7, KeyAction::MoveToTag, Arg::Int(6)),
126 + Key::new(&[MODKEY, SHIFT], keycodes::KEY_8, KeyAction::MoveToTag, Arg::Int(7)),
127 + Key::new(&[MODKEY, SHIFT], keycodes::KEY_9, KeyAction::MoveToTag, Arg::Int(8)),
128 +];
129 +
130 +// ========================================
131 +// STATUS BAR BLOCKS
132 +// ========================================
133 +pub const STATUS_BLOCKS: &[BlockConfig] = &[
134 + BlockConfig {
135 + format: "",
136 + command: BlockCommand::Battery {
137 + format_charging: "󰂄 Bat: {}%",
138 + format_discharging: "󰁹 Bat:{}%",
139 + format_full: "󰁹 Bat: {}%",
140 + },
141 + interval_secs: 30,
142 + color: GREEN,
143 + underline: true,
144 + },
145 + BlockConfig {
146 + format: " │ ",
147 + command: BlockCommand::Static(""),
148 + interval_secs: u64::MAX,
149 + color: GRAY_SEP,
150 + underline: false,
151 + },
152 + BlockConfig {
153 + format: "󰍛 {used}/{total} GB",
154 + command: BlockCommand::Ram,
155 + interval_secs: 5,
156 + color: BLUE,
157 + underline: true,
158 + },
159 + BlockConfig {
160 + format: " │ ",
161 + command: BlockCommand::Static(""),
162 + interval_secs: u64::MAX,
163 + color: GRAY_SEP,
164 + underline: false,
165 + },
166 + BlockConfig {
167 + format: " {}",
168 + command: BlockCommand::Shell("uname -r"),
169 + interval_secs: u64::MAX,
170 + color: RED,
171 + underline: true,
172 + },
173 + BlockConfig {
174 + format: " │ ",
175 + command: BlockCommand::Static(""),
176 + interval_secs: u64::MAX,
177 + color: GRAY_SEP,
178 + underline: false,
179 + },
180 + BlockConfig {
181 + format: "󰸘 {}",
182 + command: BlockCommand::DateTime("%a, %b %d - %-I:%M %P"),
183 + interval_secs: 1,
184 + color: CYAN,
185 + underline: true,
186 + },
187 +];
188 +
189 +const SHIFT: KeyButMask = KeyButMask::SHIFT;
190 +pub const WM_BINARY: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/target/release/oxwm");
+14 −29 src/lib.rs
@@ -26,7 +26,6 @@ pub struct Config {
26 26 pub gap_outer_vertical: u32,
27 27
28 28 // Basics
29 - pub terminal: String,
30 29 pub modkey: x11rb::protocol::xproto::KeyButMask,
31 30
32 31 // Tags
@@ -60,9 +59,6 @@ impl Default for Config {
60 59 const MODKEY: KeyButMask = KeyButMask::MOD4;
61 60 const SHIFT: KeyButMask = KeyButMask::SHIFT;
62 61
63 - // Detect terminal
64 - let terminal = detect_terminal();
65 -
66 62 Self {
67 63 border_width: 2,
68 64 border_focused: 0x6dade3,
@@ -73,21 +69,24 @@ impl Default for Config {
73 69 gap_inner_vertical: 0,
74 70 gap_outer_horizontal: 0,
75 71 gap_outer_vertical: 0,
76 - terminal,
77 72 modkey: MODKEY,
78 73 tags: vec!["1", "2", "3", "4", "5", "6", "7", "8", "9"]
79 74 .into_iter()
80 75 .map(String::from)
81 76 .collect(),
82 77 keybindings: vec![
83 - // Launch terminal
84 78 Key::new(
85 79 &[MODKEY],
86 80 keycodes::RETURN,
87 81 KeyAction::Spawn,
88 - Arg::Str("xterm"),
82 + Arg::Str("st"),
83 + ),
84 + Key::new(
85 + &[MODKEY],
86 + keycodes::D,
87 + KeyAction::Spawn,
88 + Arg::Array(&["sh", "-c", "dmenu_run"]),
89 89 ),
90 - // Window management
91 90 Key::new(&[MODKEY], keycodes::Q, KeyAction::KillClient, Arg::None),
92 91 Key::new(
93 92 &[MODKEY, SHIFT],
@@ -96,13 +95,10 @@ impl Default for Config {
96 95 Arg::None,
97 96 ),
98 97 Key::new(&[MODKEY], keycodes::A, KeyAction::ToggleGaps, Arg::None),
99 - // WM controls
100 98 Key::new(&[MODKEY, SHIFT], keycodes::Q, KeyAction::Quit, Arg::None),
101 99 Key::new(&[MODKEY, SHIFT], keycodes::R, KeyAction::Restart, Arg::None),
102 - // Focus
103 100 Key::new(&[MODKEY], keycodes::J, KeyAction::FocusStack, Arg::Int(-1)),
104 101 Key::new(&[MODKEY], keycodes::K, KeyAction::FocusStack, Arg::Int(1)),
105 - // View tags
106 102 Key::new(&[MODKEY], keycodes::KEY_1, KeyAction::ViewTag, Arg::Int(0)),
107 103 Key::new(&[MODKEY], keycodes::KEY_2, KeyAction::ViewTag, Arg::Int(1)),
108 104 Key::new(&[MODKEY], keycodes::KEY_3, KeyAction::ViewTag, Arg::Int(2)),
@@ -112,7 +108,6 @@ impl Default for Config {
112 108 Key::new(&[MODKEY], keycodes::KEY_7, KeyAction::ViewTag, Arg::Int(6)),
113 109 Key::new(&[MODKEY], keycodes::KEY_8, KeyAction::ViewTag, Arg::Int(7)),
114 110 Key::new(&[MODKEY], keycodes::KEY_9, KeyAction::ViewTag, Arg::Int(8)),
115 - // Move windows to tags
116 111 Key::new(
117 112 &[MODKEY, SHIFT],
118 113 keycodes::KEY_1,
@@ -168,7 +163,13 @@ impl Default for Config {
168 163 Arg::Int(8),
169 164 ),
170 165 ],
171 - status_blocks: Vec::new(),
166 + status_blocks: vec![crate::bar::BlockConfig {
167 + format: "{}",
168 + command: crate::bar::BlockCommand::DateTime("%a, %b %d - %-I:%M %P"),
169 + interval_secs: 1,
170 + color: 0x0db9d7,
171 + underline: true,
172 + }],
172 173 scheme_normal: ColorScheme {
173 174 foreground: 0xbbbbbb,
174 175 background: 0x1a1b26,
@@ -187,19 +188,3 @@ impl Default for Config {
187 188 }
188 189 }
189 190 }
190 -
191 -fn detect_terminal() -> String {
192 - let terminals = ["alacritty", "kitty", "st", "xterm", "urxvt", "termite"];
193 -
194 - for term in &terminals {
195 - if std::process::Command::new("which")
196 - .arg(term)
197 - .output()
198 - .map(|o| o.status.success())
199 - .unwrap_or(false)
200 - {
201 - return term.to_string();
202 - }
203 - }
204 - "xterm".to_string()
205 -}
+23 −0 src/main.rs.backup new file mode 100644
@@ -0,0 +1,23 @@
1 +use anyhow::Result;
2 +mod bar;
3 +mod config;
4 +mod keyboard;
5 +mod layout;
6 +mod window_manager;
7 +
8 +fn main() -> Result<()> {
9 + let args: Vec<String> = std::env::args().collect();
10 +
11 + let mut window_manager = window_manager::WindowManager::new()?;
12 + let should_restart = window_manager.run()?;
13 +
14 + drop(window_manager);
15 +
16 + if should_restart {
17 + use std::os::unix::process::CommandExt;
18 + let err = std::process::Command::new(&args[0]).args(&args[1..]).exec();
19 + eprintln!("Failed to restart: {}", err);
20 + }
21 +
22 + Ok(())
23 +}