//! Helpers for writing configuration use crate::WM; use std::{ffi::OsStr, process::Command}; /// Syntax sugar for creating [`Keybind`]s. This is helpful for writing [`crate::config::KEYBINDS`] /// /// ```rust /// /// Control + Shift + t prints "It Works!" /// bind!(ModMask::CONTROL | ModMask::SHIFT + t -> &|_| {println!("It Works!")}) /// ``` #[macro_export] macro_rules! bind { ($mod:expr , $key:ident -> $action:expr) => { Keybind { modifiers: $mod, key: Keysym::$key, action: $action, } }; } /// Execute the given command with arguments, disowning the process. pub fn spawn(cmd: &str, args: I) where I: IntoIterator, S: AsRef, { if let Err(e) = Command::new(cmd).args(args).spawn() { eprintln!("error spawning {cmd}: {e:#?}"); }; } /// Move focus to the next window on the stack pub fn focus_next(wm: &mut WM<'_>) { wm.clients.change_focus(&wm.conn, true); } /// Move focus to the next window on the stack pub fn focus_prev(wm: &mut WM<'_>) { wm.clients.change_focus(&wm.conn, false); }