Merge pull request #25 from tonybanters/aur
Browse files
AUR PKGBUILD + Desktop Session File
+37 −0 PKGBUILD new file mode 100644
| @@ -0,0 +1,37 @@ | ||
| 1 | +# Maintainer: Tony, btw <tony@tonybtw.com> | |
| 2 | +pkgname='oxwm-git' | |
| 3 | +_pkgname='oxwm' | |
| 4 | +pkgver=0.3.0.25.g0b0d9e3 | |
| 5 | +pkgrel=1 | |
| 6 | +arch=('x86_64') | |
| 7 | +url="https://github.com/tonybanters/oxwm" | |
| 8 | +pkgdesc="DWM but better with sane defaults, and not suckless." | |
| 9 | +license=('GPL-3.0-or-later') | |
| 10 | +depends=('libx11' 'libxft' 'libxcb' 'fontconfig' 'freetype2' 'libxrender') | |
| 11 | +makedepends=('cargo' 'git') | |
| 12 | +provides=('oxwm') | |
| 13 | +conflicts=('oxwm') | |
| 14 | +source=("$_pkgname::git+https://github.com/tonybanters/oxwm.git") | |
| 15 | +sha256sums=('SKIP') | |
| 16 | + | |
| 17 | +pkgver() { | |
| 18 | + cd $_pkgname | |
| 19 | + echo "$(grep '^version =' Cargo.toml | head -n1 | cut -d\" -f2).$(git rev-list --count HEAD).g$(git rev-parse --short HEAD)" | |
| 20 | +} | |
| 21 | + | |
| 22 | +build() { | |
| 23 | + cd $_pkgname | |
| 24 | + cargo build --release --locked | |
| 25 | +} | |
| 26 | + | |
| 27 | +check() { | |
| 28 | + cd $_pkgname | |
| 29 | + cargo test --release | |
| 30 | +} | |
| 31 | + | |
| 32 | +package() { | |
| 33 | + cd $_pkgname | |
| 34 | + install -Dm755 "target/release/$_pkgname" "$pkgdir/usr/bin/$_pkgname" | |
| 35 | + install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" | |
| 36 | + install -Dm644 oxwm.desktop "$pkgdir/usr/share/xsessions/oxwm.desktop" | |
| 37 | +} |
+6 −0 oxwm.desktop new file mode 100644
| @@ -0,0 +1,6 @@ | ||
| 1 | +[Desktop Entry] | |
| 2 | +Name=oxwm | |
| 3 | +Comment=DWM but better with sane defaults | |
| 4 | +Exec=oxwm | |
| 5 | +Type=Application | |
| 6 | +Keywords=wm;windowmanager;window;manager; |
+15 −0 src/bar/bar.rs
| @@ -171,6 +171,7 @@ impl Bar { | ||
| 171 | 171 | current_tags: u32, |
| 172 | 172 | occupied_tags: u32, |
| 173 | 173 | draw_blocks: bool, |
| 174 | + layout_symbol: &str, | |
| 174 | 175 | ) -> Result<(), X11Error> { |
| 175 | 176 | if !self.needs_redraw { |
| 176 | 177 | return Ok(()); |
| @@ -246,6 +247,20 @@ impl Bar { | ||
| 246 | 247 | x_position += tag_width as i16; |
| 247 | 248 | } |
| 248 | 249 | |
| 250 | + x_position += 10; | |
| 251 | + | |
| 252 | + let text_x = x_position; | |
| 253 | + let top_padding = 4; | |
| 254 | + let text_y = top_padding + font.ascent(); | |
| 255 | + | |
| 256 | + self.font_draw.draw_text( | |
| 257 | + font, | |
| 258 | + self.scheme_normal.foreground, | |
| 259 | + text_x, | |
| 260 | + text_y, | |
| 261 | + layout_symbol | |
| 262 | + ); | |
| 263 | + | |
| 249 | 264 | if draw_blocks && !self.status_text.is_empty() { |
| 250 | 265 | let padding = 10; |
| 251 | 266 | let mut x_position = self.width as i16 - padding; |
+18 −0 src/config/mod.rs
| @@ -161,6 +161,12 @@ pub fn parse_config(input: &str) -> Result<crate::Config, ConfigError> { | ||
| 161 | 161 | config_data_to_config(config_data) |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | +#[derive(Debug, Deserialize)] | |
| 165 | +struct LayoutSymbolOverrideData { | |
| 166 | + name: String, | |
| 167 | + symbol: String, | |
| 168 | +} | |
| 169 | + | |
| 164 | 170 | #[derive(Debug, Deserialize)] |
| 165 | 171 | struct ConfigData { |
| 166 | 172 | border_width: u32, |
| @@ -178,6 +184,8 @@ struct ConfigData { | ||
| 178 | 184 | modkey: ModKey, |
| 179 | 185 | |
| 180 | 186 | tags: Vec<String>, |
| 187 | + #[serde(default)] | |
| 188 | + layout_symbols: Vec<LayoutSymbolOverrideData>, | |
| 181 | 189 | keybindings: Vec<KeybindingData>, |
| 182 | 190 | status_blocks: Vec<StatusBlockData>, |
| 183 | 191 | |
| @@ -307,6 +315,15 @@ fn config_data_to_config(data: ConfigData) -> Result<crate::Config, ConfigError> | ||
| 307 | 315 | }); |
| 308 | 316 | } |
| 309 | 317 | |
| 318 | + let layout_symbols = data | |
| 319 | + .layout_symbols | |
| 320 | + .into_iter() | |
| 321 | + .map(|l| crate::LayoutSymbolOverride { | |
| 322 | + name: l.name, | |
| 323 | + symbol: l.symbol, | |
| 324 | + }) | |
| 325 | + .collect(); | |
| 326 | + | |
| 310 | 327 | Ok(crate::Config { |
| 311 | 328 | border_width: data.border_width, |
| 312 | 329 | border_focused: data.border_focused, |
| @@ -320,6 +337,7 @@ fn config_data_to_config(data: ConfigData) -> Result<crate::Config, ConfigError> | ||
| 320 | 337 | terminal: data.terminal, |
| 321 | 338 | modkey, |
| 322 | 339 | tags: data.tags, |
| 340 | + layout_symbols, | |
| 323 | 341 | keybindings, |
| 324 | 342 | status_blocks, |
| 325 | 343 | scheme_normal: crate::ColorScheme { |
+4 −1 src/layout/mod.rs
| @@ -3,6 +3,8 @@ pub mod tiling; | ||
| 3 | 3 | |
| 4 | 4 | use x11rb::protocol::xproto::Window; |
| 5 | 5 | |
| 6 | +pub type LayoutBox = Box<dyn Layout>; | |
| 7 | + | |
| 6 | 8 | pub struct GapConfig { |
| 7 | 9 | pub inner_horizontal: u32, |
| 8 | 10 | pub inner_vertical: u32, |
| @@ -14,7 +16,7 @@ pub const TILING: &str = "tiling"; | ||
| 14 | 16 | pub const NORMIE: &str = "normie"; |
| 15 | 17 | pub const FLOATING: &str = "floating"; |
| 16 | 18 | |
| 17 | -pub fn layout_from_str(s: &str) -> Result<Box<dyn Layout>, String> { | |
| 19 | +pub fn layout_from_str(s: &str) -> Result<LayoutBox, String> { | |
| 18 | 20 | match s.to_lowercase().as_str() { |
| 19 | 21 | TILING => Ok(Box::new(tiling::TilingLayout)), |
| 20 | 22 | NORMIE | FLOATING => Ok(Box::new(normie::NormieLayout)), |
| @@ -39,6 +41,7 @@ pub trait Layout { | ||
| 39 | 41 | gaps: &GapConfig, |
| 40 | 42 | ) -> Vec<WindowGeometry>; |
| 41 | 43 | fn name(&self) -> &'static str; |
| 44 | + fn symbol(&self) -> &'static str; | |
| 42 | 45 | } |
| 43 | 46 | |
| 44 | 47 | pub struct WindowGeometry { |
+4 −0 src/layout/normie.rs
| @@ -9,6 +9,10 @@ impl Layout for NormieLayout { | ||
| 9 | 9 | super::NORMIE |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | + fn symbol(&self) -> &'static str { | |
| 13 | + "><>" | |
| 14 | + } | |
| 15 | + | |
| 12 | 16 | fn arrange( |
| 13 | 17 | &self, |
| 14 | 18 | windows: &[Window], |
+4 −0 src/layout/tiling.rs
| @@ -8,6 +8,10 @@ impl Layout for TilingLayout { | ||
| 8 | 8 | super::TILING |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | + fn symbol(&self) -> &'static str { | |
| 12 | + "[]=" | |
| 13 | + } | |
| 14 | + | |
| 11 | 15 | fn arrange( |
| 12 | 16 | &self, |
| 13 | 17 | windows: &[Window], |
+11 −0 src/lib.rs
| @@ -8,11 +8,18 @@ pub mod window_manager; | ||
| 8 | 8 | |
| 9 | 9 | pub mod prelude { |
| 10 | 10 | pub use crate::ColorScheme; |
| 11 | + pub use crate::LayoutSymbolOverride; | |
| 11 | 12 | pub use crate::bar::{BlockCommand, BlockConfig}; |
| 12 | 13 | pub use crate::keyboard::{Arg, KeyAction, handlers::Key, keycodes}; |
| 13 | 14 | pub use x11rb::protocol::xproto::KeyButMask; |
| 14 | 15 | } |
| 15 | 16 | |
| 17 | +#[derive(Clone)] | |
| 18 | +pub struct LayoutSymbolOverride { | |
| 19 | + pub name: String, | |
| 20 | + pub symbol: String, | |
| 21 | +} | |
| 22 | + | |
| 16 | 23 | #[derive(Clone)] |
| 17 | 24 | pub struct Config { |
| 18 | 25 | // Appearance |
| @@ -35,6 +42,9 @@ pub struct Config { | ||
| 35 | 42 | // Tags |
| 36 | 43 | pub tags: Vec<String>, |
| 37 | 44 | |
| 45 | + // Layout symbol overrides | |
| 46 | + pub layout_symbols: Vec<LayoutSymbolOverride>, | |
| 47 | + | |
| 38 | 48 | // Keybindings |
| 39 | 49 | pub keybindings: Vec<crate::keyboard::handlers::Key>, |
| 40 | 50 | |
| @@ -81,6 +91,7 @@ impl Default for Config { | ||
| 81 | 91 | .into_iter() |
| 82 | 92 | .map(String::from) |
| 83 | 93 | .collect(), |
| 94 | + layout_symbols: vec![], | |
| 84 | 95 | keybindings: vec![ |
| 85 | 96 | Key::new( |
| 86 | 97 | vec![MODKEY], |
+17 −2 src/window_manager.rs
| @@ -4,7 +4,7 @@ use crate::errors::WmError; | ||
| 4 | 4 | use crate::keyboard::{self, Arg, KeyAction, handlers}; |
| 5 | 5 | use crate::layout::GapConfig; |
| 6 | 6 | use crate::layout::tiling::TilingLayout; |
| 7 | -use crate::layout::{Layout, layout_from_str, next_layout}; | |
| 7 | +use crate::layout::{Layout, LayoutBox, layout_from_str, next_layout}; | |
| 8 | 8 | use crate::monitor::{Monitor, detect_monitors}; |
| 9 | 9 | use std::collections::HashSet; |
| 10 | 10 | use x11rb::cursor::Handle as CursorHandle; |
| @@ -54,7 +54,7 @@ pub struct WindowManager { | ||
| 54 | 54 | root: Window, |
| 55 | 55 | screen: Screen, |
| 56 | 56 | windows: Vec<Window>, |
| 57 | - layout: Box<dyn Layout>, | |
| 57 | + layout: LayoutBox, | |
| 58 | 58 | window_tags: std::collections::HashMap<Window, TagMask>, |
| 59 | 59 | window_monitor: std::collections::HashMap<Window, usize>, |
| 60 | 60 | window_geometries: std::collections::HashMap<Window, (i16, i16, u16, u16)>, |
| @@ -789,7 +789,19 @@ impl WindowManager { | ||
| 789 | 789 | Ok(()) |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | + fn get_layout_symbol(&self) -> String { | |
| 793 | + let layout_name = self.layout.name(); | |
| 794 | + self.config | |
| 795 | + .layout_symbols | |
| 796 | + .iter() | |
| 797 | + .find(|l| l.name == layout_name) | |
| 798 | + .map(|l| l.symbol.clone()) | |
| 799 | + .unwrap_or_else(|| self.layout.symbol().to_string()) | |
| 800 | + } | |
| 801 | + | |
| 792 | 802 | fn update_bar(&mut self) -> WmResult<()> { |
| 803 | + let layout_symbol = self.get_layout_symbol(); | |
| 804 | + | |
| 793 | 805 | for (monitor_index, monitor) in self.monitors.iter().enumerate() { |
| 794 | 806 | if let Some(bar) = self.bars.get_mut(monitor_index) { |
| 795 | 807 | let mut occupied_tags: TagMask = 0; |
| @@ -808,6 +820,7 @@ impl WindowManager { | ||
| 808 | 820 | monitor.selected_tags, |
| 809 | 821 | occupied_tags, |
| 810 | 822 | draw_blocks, |
| 823 | + &layout_symbol, | |
| 811 | 824 | )?; |
| 812 | 825 | } |
| 813 | 826 | } |
| @@ -842,6 +855,7 @@ impl WindowManager { | ||
| 842 | 855 | Ok(layout) => { |
| 843 | 856 | self.layout = layout; |
| 844 | 857 | self.apply_layout()?; |
| 858 | + self.update_bar()?; | |
| 845 | 859 | } |
| 846 | 860 | Err(e) => eprintln!("Failed to change layout: {}", e), |
| 847 | 861 | } |
| @@ -854,6 +868,7 @@ impl WindowManager { | ||
| 854 | 868 | Ok(layout) => { |
| 855 | 869 | self.layout = layout; |
| 856 | 870 | self.apply_layout()?; |
| 871 | + self.update_bar()?; | |
| 857 | 872 | } |
| 858 | 873 | Err(e) => eprintln!("Failed to cycle layout: {}", e), |
| 859 | 874 | } |
+17 −0 templates/config.ron
| @@ -18,6 +18,10 @@ | ||
| 18 | 18 | modkey: Mod4, |
| 19 | 19 | |
| 20 | 20 | tags: ["1", "2", "3", "4", "5", "6", "7", "8", "9"], |
| 21 | + layout_symbols: [ | |
| 22 | + (name: "tiling", symbol: "[T]"), | |
| 23 | + (name: "normie", symbol: "[F]"), | |
| 24 | + ], | |
| 21 | 25 | |
| 22 | 26 | keybindings: [ |
| 23 | 27 | (modifiers: [Mod4], key: Return, action: Spawn, arg: "st"), |
| @@ -28,6 +32,7 @@ | ||
| 28 | 32 | (modifiers: [Mod4, Shift], key: Space, action: ToggleFloating), |
| 29 | 33 | (modifiers: [Mod4], key: F, action: ChangeLayout, arg: "normie"), |
| 30 | 34 | (modifiers: [Mod4], key: C, action: ChangeLayout, arg: "tiling"), |
| 35 | + (modifiers: [Mod1], key: N, action: CycleLayout), | |
| 31 | 36 | (modifiers: [Mod4], key: A, action: ToggleGaps), |
| 32 | 37 | (modifiers: [Mod4, Shift], key: Q, action: Quit), |
| 33 | 38 | (modifiers: [Mod4, Shift], key: R, action: Restart), |
| @@ -53,6 +58,18 @@ | ||
| 53 | 58 | (modifiers: [Mod4, Shift], key: Key7, action: MoveToTag, arg: 6), |
| 54 | 59 | (modifiers: [Mod4, Shift], key: Key8, action: MoveToTag, arg: 7), |
| 55 | 60 | (modifiers: [Mod4, Shift], key: Key9, action: MoveToTag, arg: 8), |
| 61 | + | |
| 62 | + // Moving Windows | |
| 63 | + (modifiers: [Mod4, Control], key: K, action: SmartMoveWin, arg: 0), // UP | |
| 64 | + (modifiers: [Mod4, Control], key: J, action: SmartMoveWin, arg: 1), // DOWN | |
| 65 | + (modifiers: [Mod4, Control], key: H, action: SmartMoveWin, arg: 2), // LEFT | |
| 66 | + (modifiers: [Mod4, Control], key: L, action: SmartMoveWin, arg: 3), // RIGHT | |
| 67 | + | |
| 68 | + // Exchanging Clients | |
| 69 | + (modifiers: [Mod4, Shift], key: K, action: ExchangeClient, arg: 0), // UP | |
| 70 | + (modifiers: [Mod4, Shift], key: J, action: ExchangeClient, arg: 1), // DOWN | |
| 71 | + (modifiers: [Mod4, Shift], key: H, action: ExchangeClient, arg: 2), // LEFT | |
| 72 | + (modifiers: [Mod4, Shift], key: L, action: ExchangeClient, arg: 3), // RIGHT | |
| 56 | 73 | ], |
| 57 | 74 | |
| 58 | 75 | status_blocks: [ |
+9 −1 test-config.ron
| @@ -16,7 +16,6 @@ | ||
| 16 | 16 | |
| 17 | 17 | terminal: "st", |
| 18 | 18 | modkey: Mod1, |
| 19 | - | |
| 20 | 19 | tags: ["1", "2", "3", "4", "5", "6", "7", "8", "9"], |
| 21 | 20 | |
| 22 | 21 | // Alternative icon tags (uncomment to use): |
| @@ -25,6 +24,11 @@ | ||
| 25 | 24 | // Alternative text tags (uncomment to use): |
| 26 | 25 | // tags: ["DEV", "WWW", "SYS", "DOC", "VBOX", "CHAT", "MUS", "VID", "MISC"], |
| 27 | 26 | |
| 27 | + layout_symbols: [ | |
| 28 | + (name: "tiling", symbol: "[T]"), | |
| 29 | + (name: "normie", symbol: "[F]"), | |
| 30 | + ], | |
| 31 | + | |
| 28 | 32 | keybindings: [ |
| 29 | 33 | (modifiers: [Mod1], key: Return, action: Spawn, arg: "st"), |
| 30 | 34 | (modifiers: [Mod1], key: D, action: Spawn, arg: ["sh", "-c", "dmenu_run -l 10"]), |
| @@ -41,6 +45,10 @@ | ||
| 41 | 45 | (modifiers: [Mod1], key: J, action: FocusStack, arg: -1), |
| 42 | 46 | (modifiers: [Mod1], key: K, action: FocusStack, arg: 1), |
| 43 | 47 | // Exchange client (vim-style with Mod+Shift) |
| 48 | + (modifiers: [Mod1, Control], key: K, action: SmartMoveWin, arg: 0), // UP | |
| 49 | + (modifiers: [Mod1, Control], key: J, action: SmartMoveWin, arg: 1), // DOWN | |
| 50 | + (modifiers: [Mod1, Control], key: H, action: SmartMoveWin, arg: 2), // LEFT | |
| 51 | + (modifiers: [Mod1, Control], key: L, action: SmartMoveWin, arg: 3), // RIGHT | |
| 44 | 52 | (modifiers: [Mod1, Shift], key: K, action: ExchangeClient, arg: 0), // UP |
| 45 | 53 | (modifiers: [Mod1, Shift], key: J, action: ExchangeClient, arg: 1), // DOWN |
| 46 | 54 | (modifiers: [Mod1, Shift], key: H, action: ExchangeClient, arg: 2), // LEFT |