init
This commit is contained in:
commit
155cb18ffb
3 changed files with 95 additions and 0 deletions
17
Cargo.toml
Normal file
17
Cargo.toml
Normal file
|
@ -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"
|
9
Makefile
Normal file
9
Makefile
Normal file
|
@ -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
|
69
src/main.rs
Normal file
69
src/main.rs
Normal file
|
@ -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);
|
||||
};
|
||||
|
||||
|
||||
</span><span style="color:#fa5c4b;">let</span><span style="color:#fdf4c1aa;"> config </span><span style="color:#fe8019;">= </span><span style="color:#fdf4c1aa;">Config::default();
|
||||
</span><span style="color:#fa5c4b;">let</span><span style="color:#fdf4c1aa;"> key_bindings </span><span style="color:#fe8019;">= </span><span style="color:#fabd2f;">gen_keybindings! </span><span style="color:#fdf4c1aa;">{
|
||||
</span><span style="font-style:italic;color:#928374;">// Program launchers
|
||||
</span><span style="color:#b8bb26;">"M-semicolon" </span><span style="color:#fe8019;">=> </span><span style="color:#fabd2f;">run_external!</span><span style="color:#fdf4c1aa;">(</span><span style="color:#fdf4c1;">LAUNCHER</span><span style="color:#fdf4c1aa;">);
|
||||
</span><span style="color:#b8bb26;">"M-Return" </span><span style="color:#fe8019;">=> </span><span style="color:#fabd2f;">run_external!</span><span style="color:#fdf4c1aa;">(</span><span style="color:#fdf4c1;">TERMINAL</span><span style="color:#fdf4c1aa;">);
|
||||
|
||||
</span><span style="font-style:italic;color:#928374;">// Exit Penrose (important to remember this one!)
|
||||
</span><span style="color:#b8bb26;">"M-A-C-Escape" </span><span style="color:#fe8019;">=> </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(exit);
|
||||
|
||||
</span><span style="font-style:italic;color:#928374;">// client management
|
||||
</span><span style="color:#b8bb26;">"M-j" </span><span style="color:#fe8019;">=> </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(cycle_client, Forward);
|
||||
</span><span style="color:#b8bb26;">"M-k" </span><span style="color:#fe8019;">=> </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(cycle_client, Backward);
|
||||
</span><span style="color:#b8bb26;">"M-S-j" </span><span style="color:#fe8019;">=> </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(drag_client, Forward);
|
||||
</span><span style="color:#b8bb26;">"M-S-k" </span><span style="color:#fe8019;">=> </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(drag_client, Backward);
|
||||
</span><span style="color:#b8bb26;">"M-S-f" </span><span style="color:#fe8019;">=> </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(toggle_client_fullscreen, </span><span style="color:#fe8019;">&</span><span style="color:#fdf4c1aa;">Selector::Focused);
|
||||
</span><span style="color:#b8bb26;">"M-S-q" </span><span style="color:#fe8019;">=> </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(kill_client);
|
||||
|
||||
</span><span style="font-style:italic;color:#928374;">// workspace management
|
||||
</span><span style="color:#b8bb26;">"M-Tab" </span><span style="color:#fe8019;">=> </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(toggle_workspace);
|
||||
</span><span style="color:#b8bb26;">"M-A-period" </span><span style="color:#fe8019;">=> </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(cycle_workspace, Forward);
|
||||
</span><span style="color:#b8bb26;">"M-A-comma" </span><span style="color:#fe8019;">=> </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(cycle_workspace, Backward);
|
||||
|
||||
</span><span style="font-style:italic;color:#928374;">// Layout management
|
||||
</span><span style="color:#b8bb26;">"M-grave" </span><span style="color:#fe8019;">=> </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(cycle_layout, Forward);
|
||||
</span><span style="color:#b8bb26;">"M-S-grave" </span><span style="color:#fe8019;">=> </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(cycle_layout, Backward);
|
||||
</span><span style="color:#b8bb26;">"M-A-Up" </span><span style="color:#fe8019;">=> </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(update_max_main, More);
|
||||
</span><span style="color:#b8bb26;">"M-A-Down" </span><span style="color:#fe8019;">=> </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(update_max_main, Less);
|
||||
</span><span style="color:#b8bb26;">"M-A-Right" </span><span style="color:#fe8019;">=> </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(update_main_ratio, More);
|
||||
</span><span style="color:#b8bb26;">"M-A-Left" </span><span style="color:#fe8019;">=> </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(update_main_ratio, Less);
|
||||
|
||||
refmap [ config.</span><span style="color:#fabd2f;">ws_range</span><span style="color:#fdf4c1aa;">() ] </span><span style="color:#fe8019;">in </span><span style="color:#fdf4c1aa;">{
|
||||
</span><span style="color:#b8bb26;">"M-{}" </span><span style="color:#fe8019;">=></span><span style="color:#fdf4c1aa;"> focus_workspace [ </span><span style="color:#fabd2f;">index_selectors</span><span style="color:#fdf4c1aa;">(config.</span><span style="color:#fabd2f;">workspaces</span><span style="color:#fdf4c1aa;">().</span><span style="color:#fabd2f;">len</span><span style="color:#fdf4c1aa;">()) ];
|
||||
</span><span style="color:#b8bb26;">"M-S-{}" </span><span style="color:#fe8019;">=></span><span style="color:#fdf4c1aa;"> client_to_workspace [ </span><span style="color:#fabd2f;">index_selectors</span><span style="color:#fdf4c1aa;">(config.</span><span style="color:#fabd2f;">workspaces</span><span style="color:#fdf4c1aa;">().</span><span style="color:#fabd2f;">len</span><span style="color:#fdf4c1aa;">()) ];
|
||||
};
|
||||
};
|
||||
|
||||
</span><span style="color:#fa5c4b;">let mut</span><span style="color:#fdf4c1aa;"> wm </span><span style="color:#fe8019;">= </span><span style="color:#fabd2f;">new_xcb_backed_window_manager</span><span style="color:#fdf4c1aa;">(config, </span><span style="color:#fabd2f;">vec!</span><span style="color:#fdf4c1aa;">[], </span><span style="color:#fabd2f;">logging_error_handler</span><span style="color:#fdf4c1aa;">())</span><span style="color:#fe8019;">?</span><span style="color:#fdf4c1aa;">;
|
||||
wm.</span><span style="color:#fabd2f;">grab_keys_and_run</span><span style="color:#fdf4c1aa;">(key_bindings, </span><span style="color:#fabd2f;">map!</span><span style="color:#fdf4c1aa;">{})
|
||||
}
|
Loading…
Reference in a new issue