fix something
This commit is contained in:
parent
155cb18ffb
commit
16fb08ae03
1 changed files with 52 additions and 53 deletions
105
src/main.rs
105
src/main.rs
|
@ -1,17 +1,17 @@
|
|||
#[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 penrose::{
|
||||
core::{
|
||||
bindings::KeyEventHandler,
|
||||
config::Config,
|
||||
helpers::index_selectors,
|
||||
manager::WindowManager,
|
||||
},
|
||||
logging_error_handler,
|
||||
xcb::new_xcb_backed_window_manager,
|
||||
Backward, Forward, Less, More, Selector
|
||||
};
|
||||
|
||||
use simplelog::{LevelFilter, SimpleLogger};
|
||||
|
||||
|
@ -22,48 +22,47 @@ 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;">()) ];
|
||||
// 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 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;">{})
|
||||
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!{})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue