removed rofi var and removed focus_or_spawn also fixed duplicating polybars when monitor is disconected

This commit is contained in:
Zastian Pretorius
2022-07-06 22:38:21 +01:00
parent 3b45b983c5
commit 3ab503bfe8

View File

@@ -1,9 +1,11 @@
#[macro_use] #[macro_use]
extern crate penrose; extern crate penrose;
use std::thread::sleep;
use std::time::Duration;
use penrose::{ use penrose::{
contrib::{ contrib::{
actions::{focus_or_spawn, update_monitors_via_xrandr}, actions::{update_monitors_via_xrandr},
extensions::Scratchpad, extensions::Scratchpad,
}, },
core::{ core::{
@@ -24,7 +26,6 @@ use simplelog::{LevelFilter, SimpleLogger};
// Replace these with your preferred terminal and program launcher // Replace these with your preferred terminal and program launcher
const TERMINAL: &str = "alacritty"; const TERMINAL: &str = "alacritty";
const LAUNCHER: &str = "rofi -no-lazy-greb -show drun -icon-theme 'Papirus' -show-icons";
struct StartupHook {} struct StartupHook {}
impl<X: XConn> Hook<X> for StartupHook { impl<X: XConn> Hook<X> for StartupHook {
@@ -50,7 +51,11 @@ where
fn randr_notify(&mut self, wm: &mut WindowManager<X>) -> Result<()> { fn randr_notify(&mut self, wm: &mut WindowManager<X>) -> Result<()> {
update_monitors_via_xrandr("HDMI-A-0", "eDP", RelativePosition::Left); update_monitors_via_xrandr("HDMI-A-0", "eDP", RelativePosition::Left);
if wm.n_screens() != 1 { if wm.n_screens() != 1 {
spawn!("polybar --reload barbase1") spawn!("killall polybar");
let three_seconds = Duration::from_secs(1);
sleep(three_seconds);
spawn!("polybar --reload barbase1");
spawn!("polybar --reload barbase2")
} else { } else {
spawn!("echo 'Only one screen connected'") spawn!("echo 'Only one screen connected'")
} }
@@ -90,13 +95,14 @@ fn main() -> penrose::Result<()> {
// Default percentage of the screen to fill with the main area of the layout // Default percentage of the screen to fill with the main area of the layout
let ratio = 0.5; let ratio = 0.5;
config_builder.layouts(vec![Layout::new( config_builder.layouts(vec![
Layout::new(
"[side]", "[side]",
LayoutConf::default(), LayoutConf::default(),
side_stack, side_stack,
n_main, n_main,
ratio, ratio,),
)]); ]);
let config = config_builder.build().unwrap(); let config = config_builder.build().unwrap();
let key_bindings = gen_keybindings! { let key_bindings = gen_keybindings! {
// Exit Penrose (important to remember this one!) // Exit Penrose (important to remember this one!)
@@ -134,7 +140,6 @@ fn main() -> penrose::Result<()> {
"A-S-{}" => client_to_workspace (REF); "A-S-{}" => client_to_workspace (REF);
}; };
}; };
let conn = XcbConnection::new()?; let conn = XcbConnection::new()?;
let mut wm = WindowManager::new(config, conn, hooks, logging_error_handler()); let mut wm = WindowManager::new(config, conn, hooks, logging_error_handler());