1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-01 10:41:03 +02:00

feat: introduce logging in some areas

This commit is contained in:
Jake Stanger 2022-08-25 21:53:57 +01:00
parent 6dcae66570
commit 1e38719996
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
4 changed files with 15 additions and 0 deletions

View file

@ -5,6 +5,7 @@ use color_eyre::Result;
use gtk::gdk::Monitor; use gtk::gdk::Monitor;
use gtk::prelude::*; use gtk::prelude::*;
use gtk::{Application, ApplicationWindow, Orientation}; use gtk::{Application, ApplicationWindow, Orientation};
use tracing::{debug, info};
pub fn create_bar( pub fn create_bar(
app: &Application, app: &Application,
@ -41,10 +42,12 @@ pub fn create_bar(
win.add(&content); win.add(&content);
win.connect_destroy_event(|_, _| { win.connect_destroy_event(|_, _| {
info!("Shutting down");
gtk::main_quit(); gtk::main_quit();
Inhibit(false) Inhibit(false)
}); });
debug!("Showing bar");
win.show_all(); win.show_all();
Ok(()) Ok(())
@ -104,6 +107,7 @@ fn add_modules(content: &gtk::Box, modules: Vec<ModuleConfig>, info: &ModuleInfo
let widget = $module.into_widget(&info)?; let widget = $module.into_widget(&info)?;
widget.set_widget_name($name); widget.set_widget_name($name);
content.add(&widget); content.add(&widget);
debug!("Added module of type {}", $name);
}}; }};
} }

View file

@ -110,12 +110,16 @@ fn create_bars(app: &Application, display: &Display, config: &Config) -> Result<
let outputs = serde_json::from_slice::<Vec<SwayOutput>>(&outputs)?; let outputs = serde_json::from_slice::<Vec<SwayOutput>>(&outputs)?;
debug!("Received {} outputs from Sway IPC", outputs.len());
let num_monitors = display.n_monitors(); let num_monitors = display.n_monitors();
for i in 0..num_monitors { for i in 0..num_monitors {
let monitor = display.monitor(i).ok_or_else(|| Report::msg("GTK and Sway are reporting a different number of outputs - this is a severe bug and should never happen"))?; let monitor = display.monitor(i).ok_or_else(|| Report::msg("GTK and Sway are reporting a different number of outputs - this is a severe bug and should never happen"))?;
let monitor_name = &outputs.get(i as usize).ok_or_else(|| Report::msg("GTK and Sway are reporting a different set of outputs - this is a severe bug and should never happen"))?.name; let monitor_name = &outputs.get(i as usize).ok_or_else(|| Report::msg("GTK and Sway are reporting a different set of outputs - this is a severe bug and should never happen"))?.name;
info!("Creating bar on '{}'", monitor_name);
config.monitors.as_ref().map_or_else( config.monitors.as_ref().map_or_else(
|| create_bar(app, &monitor, monitor_name, config.clone()), || create_bar(app, &monitor, monitor_name, config.clone()),
|config| { |config| {

View file

@ -59,6 +59,7 @@ impl Module<gtk::Box> for WorkspacesModule {
if self.all_monitors { if self.all_monitors {
workspaces workspaces
} else { } else {
trace!("Filtering workspaces to current monitor only");
workspaces workspaces
.into_iter() .into_iter()
.filter(|workspace| workspace.output == info.output_name) .filter(|workspace| workspace.output == info.output_name)
@ -72,6 +73,7 @@ impl Module<gtk::Box> for WorkspacesModule {
let (ui_tx, mut ui_rx) = mpsc::channel(32); let (ui_tx, mut ui_rx) = mpsc::channel(32);
trace!("Creating workspace buttons");
for workspace in workspaces { for workspace in workspaces {
let item = workspace.as_button(&name_map, &ui_tx); let item = workspace.as_button(&name_map, &ui_tx);
container.add(&item); container.add(&item);
@ -95,9 +97,11 @@ impl Module<gtk::Box> for WorkspacesModule {
}); });
{ {
trace!("Setting up sway event handler");
let menubar = container.clone(); let menubar = container.clone();
let output_name = info.output_name.to_string(); let output_name = info.output_name.to_string();
rx.attach(None, move |event| { rx.attach(None, move |event| {
debug!("Received workspace event {:?}", event);
match event.change.as_str() { match event.change.as_str() {
"focus" => { "focus" => {
let old = event.old.and_then(|old| button_map.get(&old.name)); let old = event.old.and_then(|old| button_map.get(&old.name));
@ -109,6 +113,8 @@ impl Module<gtk::Box> for WorkspacesModule {
if let Some(new) = new { if let Some(new) = new {
new.style_context().add_class("focused"); new.style_context().add_class("focused");
} }
trace!("{:?} {:?}", old, new);
} }
"init" => { "init" => {
if let Some(workspace) = event.current { if let Some(workspace) = event.current {

View file

@ -133,6 +133,7 @@ impl SwayClient {
} }
pub fn ipc(&mut self, command: IpcCommand) -> Result<Vec<u8>> { pub fn ipc(&mut self, command: IpcCommand) -> Result<Vec<u8>> {
debug!("Sending command: {:?}", command);
match self.client.ipc(command) { match self.client.ipc(command) {
Ok(res) => Ok(res), Ok(res) => Ok(res),
Err(err) => Err(get_client_error(err)), Err(err) => Err(get_client_error(err)),