From 7ab9f225632a1de377c4814c80dfa76f81d6c783 Mon Sep 17 00:00:00 2001 From: tcmal Date: Fri, 30 Aug 2024 15:14:08 +0100 Subject: Add optional autostart feature --- Cargo.toml | 1 + src/config.rs | 4 ++++ src/main.rs | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 3f9c9fe..fd29aaf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,3 +10,4 @@ xkeysym = "0.2.0" [features] debug = ["xcb/debug_atom_names"] +autostart = [] diff --git a/src/config.rs b/src/config.rs index f3b40f6..f052c22 100644 --- a/src/config.rs +++ b/src/config.rs @@ -27,6 +27,10 @@ pub const BORDER_FOCUSED: Colour = Colour::from_hex(0xff0000); /// The main modifier used for keybinds. pub const MAIN_MODIFIER: ModMask = ModMask::CONTROL; +/// Commands to run as soon as setup is done +#[cfg(feature = "autostart")] +pub const AUTOSTART_SCRIPTS: &[&[&str]] = &[]; + /// The keybinds to use. pub const KEYBINDS: Keybinds = Keybinds(&[ bind!(MAIN_MODIFIER , Return -> &|_| spawn::<_, &str>("dmenu_run", [])), diff --git a/src/main.rs b/src/main.rs index ec2475c..1f98801 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,6 +53,14 @@ fn main() -> Result<()> { #[allow(clippy::cast_sign_loss)] let mut wm = WM::new(&conn, screen_num as usize)?; + + #[cfg(feature = "autostart")] + { + for to_start in config::AUTOSTART_SCRIPTS { + helpers::spawn(to_start[0], &to_start[1..]); + } + } + wm.event_loop()?; Ok(()) -- cgit v1.2.3