|
|
@ -62,10 +62,10 @@ pub fn monitor_sway_events( |
|
|
|
} |
|
|
|
} |
|
|
|
resets += 1; |
|
|
|
resets += 1; |
|
|
|
|
|
|
|
|
|
|
|
println!("Connecting to sway for subscribing to events..."); |
|
|
|
log::debug!("Connecting to sway for subscribing to events..."); |
|
|
|
match connect_and_subscribe() { |
|
|
|
match connect_and_subscribe() { |
|
|
|
Err(err) => { |
|
|
|
Err(err) => { |
|
|
|
eprintln!("Could not connect and subscribe: {}", err); |
|
|
|
log::warn!("Could not connect and subscribe: {}", err); |
|
|
|
std::thread::sleep(std::time::Duration::from_secs(3)); |
|
|
|
std::thread::sleep(std::time::Duration::from_secs(3)); |
|
|
|
} |
|
|
|
} |
|
|
|
Ok(iter) => { |
|
|
|
Ok(iter) => { |
|
|
@ -94,7 +94,7 @@ pub fn monitor_sway_events( |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
s::Event::Shutdown(sd_ev) => { |
|
|
|
s::Event::Shutdown(sd_ev) => { |
|
|
|
println!( |
|
|
|
log::debug!( |
|
|
|
"Sway shuts down with reason '{:?}'.", |
|
|
|
"Sway shuts down with reason '{:?}'.", |
|
|
|
sd_ev.change |
|
|
|
sd_ev.change |
|
|
|
); |
|
|
|
); |
|
|
@ -103,16 +103,16 @@ pub fn monitor_sway_events( |
|
|
|
_ => show_extra_props_state = false, |
|
|
|
_ => show_extra_props_state = false, |
|
|
|
}, |
|
|
|
}, |
|
|
|
Err(e) => { |
|
|
|
Err(e) => { |
|
|
|
eprintln!("Error while receiving events: {}", e); |
|
|
|
log::warn!("Error while receiving events: {}", e); |
|
|
|
std::thread::sleep(std::time::Duration::from_secs( |
|
|
|
std::thread::sleep(std::time::Duration::from_secs( |
|
|
|
3, |
|
|
|
3, |
|
|
|
)); |
|
|
|
)); |
|
|
|
show_extra_props_state = false; |
|
|
|
show_extra_props_state = false; |
|
|
|
eprintln!("Resetting!"); |
|
|
|
log::warn!("Resetting!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if show_extra_props_state { |
|
|
|
if show_extra_props_state { |
|
|
|
println!( |
|
|
|
log::debug!( |
|
|
|
"New extra_props state:\n{:#?}", |
|
|
|
"New extra_props state:\n{:#?}", |
|
|
|
*extra_props.read().unwrap() |
|
|
|
*extra_props.read().unwrap() |
|
|
|
); |
|
|
|
); |
|
|
@ -121,7 +121,7 @@ pub fn monitor_sway_events( |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
println!("Swayr demon shutting down.") |
|
|
|
log::debug!("Swayr demon shutting down.") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn handle_window_event( |
|
|
|
fn handle_window_event( |
|
|
@ -137,28 +137,28 @@ fn handle_window_event( |
|
|
|
s::WindowChange::Focus => { |
|
|
|
s::WindowChange::Focus => { |
|
|
|
layout::maybe_auto_tile(config); |
|
|
|
layout::maybe_auto_tile(config); |
|
|
|
update_last_focus_tick(container.id, extra_props, focus_val); |
|
|
|
update_last_focus_tick(container.id, extra_props, focus_val); |
|
|
|
println!("Handled window event type {:?}", change); |
|
|
|
log::debug!("Handled window event type {:?}", change); |
|
|
|
true |
|
|
|
true |
|
|
|
} |
|
|
|
} |
|
|
|
s::WindowChange::New => { |
|
|
|
s::WindowChange::New => { |
|
|
|
layout::maybe_auto_tile(config); |
|
|
|
layout::maybe_auto_tile(config); |
|
|
|
update_last_focus_tick(container.id, extra_props, focus_val); |
|
|
|
update_last_focus_tick(container.id, extra_props, focus_val); |
|
|
|
println!("Handled window event type {:?}", change); |
|
|
|
log::debug!("Handled window event type {:?}", change); |
|
|
|
true |
|
|
|
true |
|
|
|
} |
|
|
|
} |
|
|
|
s::WindowChange::Close => { |
|
|
|
s::WindowChange::Close => { |
|
|
|
remove_extra_props(container.id, extra_props); |
|
|
|
remove_extra_props(container.id, extra_props); |
|
|
|
layout::maybe_auto_tile(config); |
|
|
|
layout::maybe_auto_tile(config); |
|
|
|
println!("Handled window event type {:?}", change); |
|
|
|
log::debug!("Handled window event type {:?}", change); |
|
|
|
true |
|
|
|
true |
|
|
|
} |
|
|
|
} |
|
|
|
s::WindowChange::Move | s::WindowChange::Floating => { |
|
|
|
s::WindowChange::Move | s::WindowChange::Floating => { |
|
|
|
layout::maybe_auto_tile(config); |
|
|
|
layout::maybe_auto_tile(config); |
|
|
|
println!("Handled window event type {:?}", change); |
|
|
|
log::debug!("Handled window event type {:?}", change); |
|
|
|
false // We don't affect the extra_props state here.
|
|
|
|
false // We don't affect the extra_props state here.
|
|
|
|
} |
|
|
|
} |
|
|
|
_ => { |
|
|
|
_ => { |
|
|
|
println!("Unhandled window event type {:?}", change); |
|
|
|
log::debug!("Unhandled window event type {:?}", change); |
|
|
|
false |
|
|
|
false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -184,7 +184,7 @@ fn handle_workspace_event( |
|
|
|
extra_props, |
|
|
|
extra_props, |
|
|
|
focus_val, |
|
|
|
focus_val, |
|
|
|
); |
|
|
|
); |
|
|
|
println!("Handled workspace event type {:?}", change); |
|
|
|
log::debug!("Handled workspace event type {:?}", change); |
|
|
|
true |
|
|
|
true |
|
|
|
} |
|
|
|
} |
|
|
|
s::WorkspaceChange::Empty => { |
|
|
|
s::WorkspaceChange::Empty => { |
|
|
@ -192,7 +192,7 @@ fn handle_workspace_event( |
|
|
|
current.expect("No current in Empty workspace event").id, |
|
|
|
current.expect("No current in Empty workspace event").id, |
|
|
|
extra_props, |
|
|
|
extra_props, |
|
|
|
); |
|
|
|
); |
|
|
|
println!("Handled workspace event type {:?}", change); |
|
|
|
log::debug!("Handled workspace event type {:?}", change); |
|
|
|
true |
|
|
|
true |
|
|
|
} |
|
|
|
} |
|
|
|
_ => false, |
|
|
|
_ => false, |
|
|
@ -229,8 +229,8 @@ pub fn serve_client_requests( |
|
|
|
extra_props: Arc<RwLock<HashMap<i64, t::ExtraProps>>>, |
|
|
|
extra_props: Arc<RwLock<HashMap<i64, t::ExtraProps>>>, |
|
|
|
) { |
|
|
|
) { |
|
|
|
match std::fs::remove_file(util::get_swayr_socket_path()) { |
|
|
|
match std::fs::remove_file(util::get_swayr_socket_path()) { |
|
|
|
Ok(()) => println!("Deleted stale socket from previous run."), |
|
|
|
Ok(()) => log::debug!("Deleted stale socket from previous run."), |
|
|
|
Err(e) => eprintln!("Could not delete socket:\n{:?}", e), |
|
|
|
Err(e) => log::error!("Could not delete socket:\n{:?}", e), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
match UnixListener::bind(util::get_swayr_socket_path()) { |
|
|
|
match UnixListener::bind(util::get_swayr_socket_path()) { |
|
|
@ -241,14 +241,14 @@ pub fn serve_client_requests( |
|
|
|
handle_client_request(stream, extra_props.clone()); |
|
|
|
handle_client_request(stream, extra_props.clone()); |
|
|
|
} |
|
|
|
} |
|
|
|
Err(err) => { |
|
|
|
Err(err) => { |
|
|
|
eprintln!("Error handling client request: {}", err); |
|
|
|
log::error!("Error handling client request: {}", err); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Err(err) => { |
|
|
|
Err(err) => { |
|
|
|
eprintln!("Could not bind socket: {}", err) |
|
|
|
log::error!("Could not bind socket: {}", err) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -265,12 +265,12 @@ fn handle_client_request( |
|
|
|
extra_props, |
|
|
|
extra_props, |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
eprintln!( |
|
|
|
log::error!( |
|
|
|
"Could not serialize following string to SwayrCommand.\n{}", |
|
|
|
"Could not serialize following string to SwayrCommand.\n{}", |
|
|
|
cmd_str |
|
|
|
cmd_str |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
eprintln!("Could not read command from client."); |
|
|
|
log::error!("Could not read command from client."); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|