tony / oxwm

Branch: fe6d8c8
Switch branches/tags
master
tonybtw Fixed main.rs to just launch with sane defaults and accomdate for rare situation where user will not have a Cargo.toml but will have a config.rs... 18f19a1 2025-10-13
141 lines · 5.4 KB Raw Blame History
1 use oxwm::ColorScheme;
2 use oxwm::prelude::*;
3
4 // ========================================
5 // APPEARANCE
6 // ========================================
7 pub const BORDER_WIDTH: u32 = 2;
8 pub const BORDER_FOCUSED: u32 = 0x6dade3;
9 pub const BORDER_UNFOCUSED: u32 = 0xbbbbbb;
10 pub const FONT: &str = "monospace:size=12";
11
12 // ========================================
13 // GAPS (Vanity Gaps)
14 // ========================================
15 pub const GAPS_ENABLED: bool = true;
16 pub const GAP_INNER_HORIZONTAL: u32 = 6;
17 pub const GAP_INNER_VERTICAL: u32 = 6;
18 pub const GAP_OUTER_HORIZONTAL: u32 = 6;
19 pub const GAP_OUTER_VERTICAL: u32 = 6;
20
21 // ========================================
22 // DEFAULTS
23 // ========================================
24 pub const TERMINAL: &str = "st";
25 pub const MODKEY: KeyButMask = KeyButMask::MOD4;
26
27 // ========================================
28 // TAGS (Workspaces)
29 // ========================================
30 pub const TAG_COUNT: usize = 9;
31 pub const TAGS: [&str; TAG_COUNT] = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
32
33 // ========================================
34 // BAR COLORS
35 // ========================================
36 const GRAY_DARK: u32 = 0x1a1b26;
37 const GRAY_MID: u32 = 0x444444;
38 const GRAY_LIGHT: u32 = 0xbbbbbb;
39 const CYAN: u32 = 0x0db9d7;
40 const MAGENTA: u32 = 0xad8ee6;
41
42 pub const SCHEME_NORMAL: ColorScheme = ColorScheme {
43 foreground: GRAY_LIGHT,
44 background: GRAY_DARK,
45 underline: GRAY_MID,
46 };
47
48 pub const SCHEME_OCCUPIED: ColorScheme = ColorScheme {
49 foreground: CYAN,
50 background: GRAY_DARK,
51 underline: CYAN,
52 };
53
54 pub const SCHEME_SELECTED: ColorScheme = ColorScheme {
55 foreground: CYAN,
56 background: GRAY_DARK,
57 underline: MAGENTA,
58 };
59
60 // ========================================
61 // KEYBINDINGS
62 // ========================================
63 const SHIFT: KeyButMask = KeyButMask::SHIFT;
64
65 #[rustfmt::skip]
66 pub const KEYBINDINGS: &[Key] = &[
67 // Launch applications
68 Key::new(&[MODKEY], keycodes::RETURN, KeyAction::Spawn, Arg::Str(TERMINAL)),
69 Key::new(&[MODKEY], keycodes::D, KeyAction::Spawn, Arg::Array(&["sh", "-c", "dmenu_run"])),
70
71 // Window management
72 Key::new(&[MODKEY], keycodes::Q, KeyAction::KillClient, Arg::None),
73 Key::new(&[MODKEY, SHIFT], keycodes::F, KeyAction::ToggleFullScreen, Arg::None),
74 Key::new(&[MODKEY], keycodes::A, KeyAction::ToggleGaps, Arg::None),
75
76 // WM controls
77 Key::new(&[MODKEY, SHIFT], keycodes::Q, KeyAction::Quit, Arg::None),
78 Key::new(&[MODKEY, SHIFT], keycodes::R, KeyAction::Restart, Arg::None),
79
80 // Focus
81 Key::new(&[MODKEY], keycodes::J, KeyAction::FocusStack, Arg::Int(-1)),
82 Key::new(&[MODKEY], keycodes::K, KeyAction::FocusStack, Arg::Int(1)),
83
84 // View tags (workspaces)
85 Key::new(&[MODKEY], keycodes::KEY_1, KeyAction::ViewTag, Arg::Int(0)),
86 Key::new(&[MODKEY], keycodes::KEY_2, KeyAction::ViewTag, Arg::Int(1)),
87 Key::new(&[MODKEY], keycodes::KEY_3, KeyAction::ViewTag, Arg::Int(2)),
88 Key::new(&[MODKEY], keycodes::KEY_4, KeyAction::ViewTag, Arg::Int(3)),
89 Key::new(&[MODKEY], keycodes::KEY_5, KeyAction::ViewTag, Arg::Int(4)),
90 Key::new(&[MODKEY], keycodes::KEY_6, KeyAction::ViewTag, Arg::Int(5)),
91 Key::new(&[MODKEY], keycodes::KEY_7, KeyAction::ViewTag, Arg::Int(6)),
92 Key::new(&[MODKEY], keycodes::KEY_8, KeyAction::ViewTag, Arg::Int(7)),
93 Key::new(&[MODKEY], keycodes::KEY_9, KeyAction::ViewTag, Arg::Int(8)),
94
95 // Move windows to tags
96 Key::new(&[MODKEY, SHIFT], keycodes::KEY_1, KeyAction::MoveToTag, Arg::Int(0)),
97 Key::new(&[MODKEY, SHIFT], keycodes::KEY_2, KeyAction::MoveToTag, Arg::Int(1)),
98 Key::new(&[MODKEY, SHIFT], keycodes::KEY_3, KeyAction::MoveToTag, Arg::Int(2)),
99 Key::new(&[MODKEY, SHIFT], keycodes::KEY_4, KeyAction::MoveToTag, Arg::Int(3)),
100 Key::new(&[MODKEY, SHIFT], keycodes::KEY_5, KeyAction::MoveToTag, Arg::Int(4)),
101 Key::new(&[MODKEY, SHIFT], keycodes::KEY_6, KeyAction::MoveToTag, Arg::Int(5)),
102 Key::new(&[MODKEY, SHIFT], keycodes::KEY_7, KeyAction::MoveToTag, Arg::Int(6)),
103 Key::new(&[MODKEY, SHIFT], keycodes::KEY_8, KeyAction::MoveToTag, Arg::Int(7)),
104 Key::new(&[MODKEY, SHIFT], keycodes::KEY_9, KeyAction::MoveToTag, Arg::Int(8)),
105 ];
106
107 // ========================================
108 // STATUS BAR BLOCKS
109 // ========================================
110 pub const STATUS_BLOCKS: &[BlockConfig] = &[BlockConfig {
111 format: "{}",
112 command: BlockCommand::DateTime("%a, %b %d - %-I:%M %P"),
113 interval_secs: 1,
114 color: CYAN,
115 underline: true,
116 }];
117
118 // ========================================
119 // BUILD CONFIG FROM CONSTANTS
120 // ========================================
121 pub fn build_config() -> oxwm::Config {
122 oxwm::Config {
123 border_width: BORDER_WIDTH,
124 border_focused: BORDER_FOCUSED,
125 border_unfocused: BORDER_UNFOCUSED,
126 font: FONT.to_string(),
127 gaps_enabled: GAPS_ENABLED,
128 gap_inner_horizontal: GAP_INNER_HORIZONTAL,
129 gap_inner_vertical: GAP_INNER_VERTICAL,
130 gap_outer_horizontal: GAP_OUTER_HORIZONTAL,
131 gap_outer_vertical: GAP_OUTER_VERTICAL,
132 terminal: TERMINAL.to_string(),
133 modkey: MODKEY,
134 tags: TAGS.iter().map(|s| s.to_string()).collect(),
135 keybindings: KEYBINDINGS.to_vec(),
136 status_blocks: STATUS_BLOCKS.to_vec(),
137 scheme_normal: SCHEME_NORMAL,
138 scheme_occupied: SCHEME_OCCUPIED,
139 scheme_selected: SCHEME_SELECTED,
140 }
141 }