oxwm

https://git.tonybtw.com/oxwm.git git://git.tonybtw.com/oxwm.git

removed old conf

Commit
52cdcac413d0a48c42c8e235dfb4fd1ff888db08
Parent
3b8534f
Author
tonybtw <tonybtw@tonybtw.com>
Date
2025-10-15 04:07:25

Diff

diff --git a/src/bin/main.rs.backup b/src/bin/main.rs.backup
deleted file mode 100644
index b3b6974..0000000
--- a/src/bin/main.rs.backup
+++ /dev/null
@@ -1,229 +0,0 @@
-use anyhow::Result;
-use std::path::PathBuf;
-
-fn main() -> Result<()> {
-    let args: Vec<String> = std::env::args().collect();
-
-    match args.get(1).map(|s| s.as_str()) {
-        Some("--version") => {
-            println!("oxwm {}", env!("CARGO_PKG_VERSION"));
-            return Ok(());
-        }
-        Some("--help") => {
-            print_help();
-            return Ok(());
-        }
-        Some("--init") => {
-            init_config()?;
-            println!("āœ“ Config created at ~/.config/oxwm/config.rs");
-            println!("  Edit and reload with Mod+Shift+R");
-            return Ok(());
-        }
-        Some("--recompile") => {
-            recompile_config()?;
-            return Ok(());
-        }
-        _ => {}
-    }
-
-    let config_dir = get_config_path();
-    let user_bin = config_dir.join("target/release/oxwm-user");
-
-    if user_bin.exists() {
-        use std::os::unix::process::CommandExt;
-        let err = std::process::Command::new(&user_bin)
-            .args(&args[1..])
-            .exec();
-        eprintln!("Failed to exec user binary: {}", err);
-        std::process::exit(1);
-    }
-
-    let config = oxwm::Config::default();
-    run_wm_with_config(config, &args)?;
-
-    Ok(())
-}
-
-fn run_wm_with_config(config: oxwm::Config, args: &[String]) -> Result<()> {
-    let mut wm = oxwm::window_manager::WindowManager::new(config)?;
-    let should_restart = wm.run()?;
-
-    drop(wm);
-
-    if should_restart {
-        use std::os::unix::process::CommandExt;
-        let err = std::process::Command::new(&args[0]).args(&args[1..]).exec();
-        eprintln!("Failed to restart: {}", err);
-    }
-
-    Ok(())
-}
-
-fn should_recompile(config: &PathBuf, binary: &PathBuf) -> Result<bool> {
-    let config_dir = get_config_path();
-    let binary_time = std::fs::metadata(binary)?.modified()?;
-
-    let watch_files = ["config.rs", "Cargo.toml"];
-
-    for filename in &watch_files {
-        let path = config_dir.join(filename);
-        if !path.exists() {
-            continue;
-        }
-
-        let file_time = std::fs::metadata(&path)?.modified()?;
-        if file_time > binary_time {
-            return Ok(true);
-        }
-    }
-
-    Ok(false)
-}
-
-fn init_config() -> Result<()> {
-    let config_dir = get_config_path();
-    std::fs::create_dir_all(&config_dir)?;
-
-    let config_template = include_str!("../../templates/config.rs");
-    std::fs::write(config_dir.join("config.rs"), config_template)?;
-
-    let main_template = include_str!("../../templates/main.rs");
-    std::fs::write(config_dir.join("main.rs"), main_template)?;
-
-    let cargo_toml = r#"[package]
-name = "oxwm-user"
-version = "0.1.0"
-edition = "2024"
-
-[dependencies]
-oxwm = { git = "https://github.com/tonybanters/oxwm" }
-anyhow = "1"
-
-[[bin]]
-name = "oxwm-user"
-path = "main.rs"
-"#;
-
-    std::fs::write(config_dir.join("Cargo.toml"), cargo_toml)?;
-    std::fs::write(config_dir.join(".gitignore"), "target/\nCargo.lock\n")?;
-
-    if is_nixos() {
-        let shell_nix = r#"{ pkgs ? import <nixpkgs> {} }:
-pkgs.mkShell {
-  buildInputs = with pkgs; [
-    rustc
-    cargo
-    pkg-config
-    xorg.libX11
-    xorg.libXft
-    xorg.libXrender
-    freetype
-    fontconfig
-  ];
-}
-"#;
-        std::fs::write(config_dir.join("shell.nix"), shell_nix)?;
-        println!("āœ“ Created shell.nix for NixOS");
-    }
-
-    Ok(())
-}
-
-fn recompile_config() -> Result<()> {
-    let config_dir = get_config_path();
-
-    if !config_dir.join("config.rs").exists() {
-        anyhow::bail!("No config found. Run: oxwm --init");
-    }
-
-    println!("Compiling oxwm configuration...");
-
-    let build_method = detect_build_method();
-
-    let output = match build_method {
-        BuildMethod::NixFlake => {
-            println!("Using nix flake build...");
-            std::process::Command::new("nix")
-                .args(&["build", ".#", "--no-link"])
-                .current_dir(&config_dir)
-                .output()?
-        }
-        BuildMethod::NixBuild => {
-            println!("Using nix-shell...");
-            std::process::Command::new("nix-shell")
-                .args(&["--run", "cargo build --release"])
-                .current_dir(&config_dir)
-                .output()?
-        }
-        BuildMethod::Cargo => std::process::Command::new("cargo")
-            .args(&["build", "--release"])
-            .current_dir(&config_dir)
-            .output()?,
-    };
-
-    if !output.status.success() {
-        let stderr = String::from_utf8_lossy(&output.stderr);
-        eprintln!("\nāŒ Compilation failed:\n{}", stderr);
-        anyhow::bail!("Failed to compile configuration");
-    }
-
-    println!("āœ“ Compiled successfully.");
-    println!("  Restart oxwm to use new config");
-
-    Ok(())
-}
-
-#[derive(Debug)]
-enum BuildMethod {
-    NixFlake,
-    NixBuild,
-    Cargo,
-}
-
-fn detect_build_method() -> BuildMethod {
-    let config_dir = get_config_path();
-
-    if config_dir.join("flake.nix").exists() {
-        println!("Detected flake.nix, will use nix flake for recompilation");
-        return BuildMethod::NixFlake;
-    }
-
-    if config_dir.join("default.nix").exists() || config_dir.join("shell.nix").exists() {
-        println!("Detected nix files, will use nix-shell for recompilation");
-        return BuildMethod::NixBuild;
-    }
-
-    println!("Will use cargo for recompilation");
-    BuildMethod::Cargo
-}
-
-fn is_nixos() -> bool {
-    std::path::Path::new("/etc/NIXOS").exists()
-        || std::path::Path::new("/run/current-system/nixos-version").exists()
-        || std::env::var("NIX_PATH").is_ok()
-}
-
-fn get_config_path() -> PathBuf {
-    dirs::config_dir()
-        .expect("Could not find config directory")
-        .join("oxwm")
-}
-
-fn get_user_binary_path() -> PathBuf {
-    get_config_path().join("oxwm-user")
-}
-
-fn print_help() {
-    println!("OXWM - A dynamic window manager written in Rust\n");
-    println!("USAGE:");
-    println!("    oxwm [OPTIONS]\n");
-    println!("OPTIONS:");
-    println!("    --init         Create default config in ~/.config/oxwm");
-    println!("    --recompile    Recompile user configuration");
-    println!("    --version      Print version information");
-    println!("    --help         Print this help message\n");
-    println!("CONFIG:");
-    println!("    First run: Creates config at ~/.config/oxwm/config.rs");
-    println!("    Edit your config and run 'oxwm --recompile'");
-    println!("    Use Mod+Shift+R to hot-reload after recompiling\n");
-}
diff --git a/templates/config.rs b/templates/config.rs
deleted file mode 100644
index 9d1fb07..0000000
--- a/templates/config.rs
+++ /dev/null
@@ -1,141 +0,0 @@
-use oxwm::ColorScheme;
-use oxwm::prelude::*;
-
-// ========================================
-// APPEARANCE
-// ========================================
-pub const BORDER_WIDTH: u32 = 2;
-pub const BORDER_FOCUSED: u32 = 0x6dade3;
-pub const BORDER_UNFOCUSED: u32 = 0xbbbbbb;
-pub const FONT: &str = "monospace:size=12";
-
-// ========================================
-// GAPS (Vanity Gaps)
-// ========================================
-pub const GAPS_ENABLED: bool = true;
-pub const GAP_INNER_HORIZONTAL: u32 = 6;
-pub const GAP_INNER_VERTICAL: u32 = 6;
-pub const GAP_OUTER_HORIZONTAL: u32 = 6;
-pub const GAP_OUTER_VERTICAL: u32 = 6;
-
-// ========================================
-// DEFAULTS
-// ========================================
-pub const TERMINAL: &str = "st";
-pub const MODKEY: KeyButMask = KeyButMask::MOD4;
-
-// ========================================
-// TAGS (Workspaces)
-// ========================================
-pub const TAG_COUNT: usize = 9;
-pub const TAGS: [&str; TAG_COUNT] = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
-
-// ========================================
-// BAR COLORS
-// ========================================
-const GRAY_DARK: u32 = 0x1a1b26;
-const GRAY_MID: u32 = 0x444444;
-const GRAY_LIGHT: u32 = 0xbbbbbb;
-const CYAN: u32 = 0x0db9d7;
-const MAGENTA: u32 = 0xad8ee6;
-
-pub const SCHEME_NORMAL: ColorScheme = ColorScheme {
-    foreground: GRAY_LIGHT,
-    background: GRAY_DARK,
-    underline: GRAY_MID,
-};
-
-pub const SCHEME_OCCUPIED: ColorScheme = ColorScheme {
-    foreground: CYAN,
-    background: GRAY_DARK,
-    underline: CYAN,
-};
-
-pub const SCHEME_SELECTED: ColorScheme = ColorScheme {
-    foreground: CYAN,
-    background: GRAY_DARK,
-    underline: MAGENTA,
-};
-
-// ========================================
-// KEYBINDINGS
-// ========================================
-const SHIFT: KeyButMask = KeyButMask::SHIFT;
-
-#[rustfmt::skip]
-pub const KEYBINDINGS: &[Key] = &[
-    // Launch applications
-    Key::new(&[MODKEY],        keycodes::RETURN, KeyAction::Spawn,      Arg::Str(TERMINAL)),
-    Key::new(&[MODKEY],        keycodes::D,      KeyAction::Spawn,      Arg::Array(&["sh", "-c", "dmenu_run"])),
-    
-    // Window management
-    Key::new(&[MODKEY],        keycodes::Q,      KeyAction::KillClient, Arg::None),
-    Key::new(&[MODKEY, SHIFT], keycodes::F,      KeyAction::ToggleFullScreen, Arg::None),
-    Key::new(&[MODKEY],        keycodes::A,      KeyAction::ToggleGaps, Arg::None),
-    
-    // WM controls
-    Key::new(&[MODKEY, SHIFT], keycodes::Q,      KeyAction::Quit,       Arg::None),
-    Key::new(&[MODKEY, SHIFT], keycodes::R,      KeyAction::Restart,    Arg::None),
-    
-    // Focus
-    Key::new(&[MODKEY],        keycodes::J,      KeyAction::FocusStack, Arg::Int(-1)),
-    Key::new(&[MODKEY],        keycodes::K,      KeyAction::FocusStack, Arg::Int(1)),
-    
-    // View tags (workspaces)
-    Key::new(&[MODKEY], keycodes::KEY_1, KeyAction::ViewTag, Arg::Int(0)),
-    Key::new(&[MODKEY], keycodes::KEY_2, KeyAction::ViewTag, Arg::Int(1)),
-    Key::new(&[MODKEY], keycodes::KEY_3, KeyAction::ViewTag, Arg::Int(2)),
-    Key::new(&[MODKEY], keycodes::KEY_4, KeyAction::ViewTag, Arg::Int(3)),
-    Key::new(&[MODKEY], keycodes::KEY_5, KeyAction::ViewTag, Arg::Int(4)),
-    Key::new(&[MODKEY], keycodes::KEY_6, KeyAction::ViewTag, Arg::Int(5)),
-    Key::new(&[MODKEY], keycodes::KEY_7, KeyAction::ViewTag, Arg::Int(6)),
-    Key::new(&[MODKEY], keycodes::KEY_8, KeyAction::ViewTag, Arg::Int(7)),
-    Key::new(&[MODKEY], keycodes::KEY_9, KeyAction::ViewTag, Arg::Int(8)),
-    
-    // Move windows to tags
-    Key::new(&[MODKEY, SHIFT], keycodes::KEY_1, KeyAction::MoveToTag, Arg::Int(0)),
-    Key::new(&[MODKEY, SHIFT], keycodes::KEY_2, KeyAction::MoveToTag, Arg::Int(1)),
-    Key::new(&[MODKEY, SHIFT], keycodes::KEY_3, KeyAction::MoveToTag, Arg::Int(2)),
-    Key::new(&[MODKEY, SHIFT], keycodes::KEY_4, KeyAction::MoveToTag, Arg::Int(3)),
-    Key::new(&[MODKEY, SHIFT], keycodes::KEY_5, KeyAction::MoveToTag, Arg::Int(4)),
-    Key::new(&[MODKEY, SHIFT], keycodes::KEY_6, KeyAction::MoveToTag, Arg::Int(5)),
-    Key::new(&[MODKEY, SHIFT], keycodes::KEY_7, KeyAction::MoveToTag, Arg::Int(6)),
-    Key::new(&[MODKEY, SHIFT], keycodes::KEY_8, KeyAction::MoveToTag, Arg::Int(7)),
-    Key::new(&[MODKEY, SHIFT], keycodes::KEY_9, KeyAction::MoveToTag, Arg::Int(8)),
-];
-
-// ========================================
-// STATUS BAR BLOCKS
-// ========================================
-pub const STATUS_BLOCKS: &[BlockConfig] = &[BlockConfig {
-    format: "{}",
-    command: BlockCommand::DateTime("%a, %b %d - %-I:%M %P"),
-    interval_secs: 1,
-    color: CYAN,
-    underline: true,
-}];
-
-// ========================================
-// BUILD CONFIG FROM CONSTANTS
-// ========================================
-pub fn build_config() -> oxwm::Config {
-    oxwm::Config {
-        border_width: BORDER_WIDTH,
-        border_focused: BORDER_FOCUSED,
-        border_unfocused: BORDER_UNFOCUSED,
-        font: FONT.to_string(),
-        gaps_enabled: GAPS_ENABLED,
-        gap_inner_horizontal: GAP_INNER_HORIZONTAL,
-        gap_inner_vertical: GAP_INNER_VERTICAL,
-        gap_outer_horizontal: GAP_OUTER_HORIZONTAL,
-        gap_outer_vertical: GAP_OUTER_VERTICAL,
-        terminal: TERMINAL.to_string(),
-        modkey: MODKEY,
-        tags: TAGS.iter().map(|s| s.to_string()).collect(),
-        keybindings: KEYBINDINGS.to_vec(),
-        status_blocks: STATUS_BLOCKS.to_vec(),
-        scheme_normal: SCHEME_NORMAL,
-        scheme_occupied: SCHEME_OCCUPIED,
-        scheme_selected: SCHEME_SELECTED,
-    }
-}