fix something

This commit is contained in:
Ohio2 2021-07-28 12:25:53 +02:00
parent 155cb18ffb
commit 16fb08ae03

View file

@ -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;">&quot;M-semicolon&quot; </span><span style="color:#fe8019;">=&gt; </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;">&quot;M-Return&quot; </span><span style="color:#fe8019;">=&gt; </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;">&quot;M-A-C-Escape&quot; </span><span style="color:#fe8019;">=&gt; </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;">&quot;M-j&quot; </span><span style="color:#fe8019;">=&gt; </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(cycle_client, Forward);
</span><span style="color:#b8bb26;">&quot;M-k&quot; </span><span style="color:#fe8019;">=&gt; </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(cycle_client, Backward);
</span><span style="color:#b8bb26;">&quot;M-S-j&quot; </span><span style="color:#fe8019;">=&gt; </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(drag_client, Forward);
</span><span style="color:#b8bb26;">&quot;M-S-k&quot; </span><span style="color:#fe8019;">=&gt; </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(drag_client, Backward);
</span><span style="color:#b8bb26;">&quot;M-S-f&quot; </span><span style="color:#fe8019;">=&gt; </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(toggle_client_fullscreen, </span><span style="color:#fe8019;">&amp;</span><span style="color:#fdf4c1aa;">Selector::Focused);
</span><span style="color:#b8bb26;">&quot;M-S-q&quot; </span><span style="color:#fe8019;">=&gt; </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;">&quot;M-Tab&quot; </span><span style="color:#fe8019;">=&gt; </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(toggle_workspace);
</span><span style="color:#b8bb26;">&quot;M-A-period&quot; </span><span style="color:#fe8019;">=&gt; </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(cycle_workspace, Forward);
</span><span style="color:#b8bb26;">&quot;M-A-comma&quot; </span><span style="color:#fe8019;">=&gt; </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;">&quot;M-grave&quot; </span><span style="color:#fe8019;">=&gt; </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(cycle_layout, Forward);
</span><span style="color:#b8bb26;">&quot;M-S-grave&quot; </span><span style="color:#fe8019;">=&gt; </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(cycle_layout, Backward);
</span><span style="color:#b8bb26;">&quot;M-A-Up&quot; </span><span style="color:#fe8019;">=&gt; </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(update_max_main, More);
</span><span style="color:#b8bb26;">&quot;M-A-Down&quot; </span><span style="color:#fe8019;">=&gt; </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(update_max_main, Less);
</span><span style="color:#b8bb26;">&quot;M-A-Right&quot; </span><span style="color:#fe8019;">=&gt; </span><span style="color:#fabd2f;">run_internal!</span><span style="color:#fdf4c1aa;">(update_main_ratio, More);
</span><span style="color:#b8bb26;">&quot;M-A-Left&quot; </span><span style="color:#fe8019;">=&gt; </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;">&quot;M-{}&quot; </span><span style="color:#fe8019;">=&gt;</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;">&quot;M-S-{}&quot; </span><span style="color:#fe8019;">=&gt;</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!{})
}