From 155cb18ffb8b98661d6e42f85b56bfa67ad5ab8e Mon Sep 17 00:00:00 2001 From: Ohio2 Date: Wed, 28 Jul 2021 12:22:19 +0200 Subject: [PATCH] init --- Cargo.toml | 17 +++++++++++++ Makefile | 9 +++++++ src/main.rs | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 Cargo.toml create mode 100644 Makefile create mode 100644 src/main.rs diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..9896c15 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "violet" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +penrose = "0.2.0" +log = "0.4.14" +nix = "0.17.0" +strum = "0.19.5" +strum_macros = "0.19.4" +thiserror = "1.0.26" +paste = "1.0.5" +serde_json = "1.0.64" +simplelog = "0.8.0" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..76145ca --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +ohio2-penrose: + cargo build --release +install: + scp target/debug/ohio2-penrose /usr/bin/ohio2-penrose +remove: + rm /usr/bin/ohio2-penrose +clean: + rm Cargo.lock + rm -rf target diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..5414160 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,69 @@ +#[macro_use] +extern crate penrose; +use penrose::{ +core::{ +bindings::KeyEventHandler, +config::Config, +helpers::index_selectors, +manager::WindowManager, +}, +logging_error_handler, +xcb::new_xcb_backed_window_manager, +Backward, Forward, Less, More, +}; + + +use simplelog::{LevelFilter, SimpleLogger}; + + +// Replace these with your preferred terminal and program launcher +const TERMINAL: &str = "alacritty"; +const LAUNCHER: &str = "dmenu_run"; + + +fn main() -> penrose::Result<()> { +// Initialise the logger (use LevelFilter::Debug to enable debug logging) +if let Err(e) = SimpleLogger::init(LevelFilter::Info, simplelog::Config::default()) { +panic!("unable to set log level: {}", e); +}; + + +let config = Config::default(); +let key_bindings = gen_keybindings! { + // Program launchers + "M-semicolon" => run_external!(LAUNCHER); + "M-Return" => run_external!(TERMINAL); + + // Exit Penrose (important to remember this one!) + "M-A-C-Escape" => run_internal!(exit); + + // client management + "M-j" => run_internal!(cycle_client, Forward); + "M-k" => run_internal!(cycle_client, Backward); + "M-S-j" => run_internal!(drag_client, Forward); + "M-S-k" => run_internal!(drag_client, Backward); + "M-S-f" => run_internal!(toggle_client_fullscreen, &Selector::Focused); + "M-S-q" => run_internal!(kill_client); + + // workspace management + "M-Tab" => run_internal!(toggle_workspace); + "M-A-period" => run_internal!(cycle_workspace, Forward); + "M-A-comma" => run_internal!(cycle_workspace, Backward); + + // Layout management + "M-grave" => run_internal!(cycle_layout, Forward); + "M-S-grave" => run_internal!(cycle_layout, Backward); + "M-A-Up" => run_internal!(update_max_main, More); + "M-A-Down" => run_internal!(update_max_main, Less); + "M-A-Right" => run_internal!(update_main_ratio, More); + "M-A-Left" => run_internal!(update_main_ratio, Less); + + refmap [ config.ws_range() ] in { + "M-{}" => focus_workspace [ index_selectors(config.workspaces().len()) ]; + "M-S-{}" => client_to_workspace [ index_selectors(config.workspaces().len()) ]; + }; +}; + +let mut wm = new_xcb_backed_window_manager(config, vec![], logging_error_handler())?; +wm.grab_keys_and_run(key_bindings, map!{}) +}