summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs2
-rw-r--r--src/state.rs19
-rw-r--r--src/wm_info_provider/hyprland.rs2
-rw-r--r--src/wm_info_provider/river.rs3
4 files changed, 16 insertions, 10 deletions
diff --git a/src/main.rs b/src/main.rs
index 18d604e..076d17b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -96,7 +96,7 @@ fn main() -> anyhow::Result<()> {
.unwrap()
.child
.kill();
- ctx.state.set_error(ctx.conn, e);
+ ctx.state.set_error(ctx.conn, "status", e);
Ok(event_loop::Action::Unregister)
}
}
diff --git a/src/state.rs b/src/state.rs
index 279aac3..72bf3f0 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -33,6 +33,7 @@ pub struct State {
pub pending_outputs: Vec<PendingOutput>,
pub hidden: bool,
+ pub has_error: bool,
pub bars: Vec<Bar>,
pub shared_state: SharedState,
@@ -99,6 +100,7 @@ impl State {
.collect(),
hidden: false,
+ has_error: false,
bars: Vec::new(),
shared_state: SharedState {
@@ -114,27 +116,30 @@ impl State {
};
if let Err(e) = error {
- this.set_error(conn, e.to_string());
+ this.set_error(conn, "init", e.to_string());
}
this
}
pub fn set_blocks(&mut self, conn: &mut Connection<Self>, blocks: Vec<Block>) {
- self.shared_state
- .blocks_cache
- .process_new_blocks(&self.shared_state.config, blocks);
- self.draw_all(conn);
+ if !self.has_error {
+ self.shared_state
+ .blocks_cache
+ .process_new_blocks(&self.shared_state.config, blocks);
+ self.draw_all(conn);
+ }
}
- pub fn set_error(&mut self, conn: &mut Connection<Self>, error: impl Display) {
+ pub fn set_error(&mut self, conn: &mut Connection<Self>, context: &str, error: impl Display) {
self.set_blocks(
conn,
vec![Block {
- full_text: error.to_string(),
+ full_text: format!("{context}: {error}"),
..Default::default()
}],
);
+ self.has_error = true;
}
pub fn draw_all(&mut self, conn: &mut Connection<Self>) {
diff --git a/src/wm_info_provider/hyprland.rs b/src/wm_info_provider/hyprland.rs
index 0d7d4ec..19a259a 100644
--- a/src/wm_info_provider/hyprland.rs
+++ b/src/wm_info_provider/hyprland.rs
@@ -39,7 +39,7 @@ impl WmInfoProvider for HyprlandInfoProvider {
match hyprland_cb(ctx.conn, ctx.state) {
Ok(()) => Ok(event_loop::Action::Keep),
Err(e) => {
- ctx.state.set_error(ctx.conn, e);
+ ctx.state.set_error(ctx.conn, "hyprland", e);
Ok(event_loop::Action::Unregister)
}
}
diff --git a/src/wm_info_provider/river.rs b/src/wm_info_provider/river.rs
index 6b3c8b0..61b7e2b 100644
--- a/src/wm_info_provider/river.rs
+++ b/src/wm_info_provider/river.rs
@@ -211,6 +211,7 @@ fn seat_status_cb(ctx: EventCtx<State, ZriverSeatStatusV1>) {
fn river_command_cb(ctx: EventCtx<State, ZriverCommandCallbackV1>) {
if let zriver_command_callback_v1::Event::Failure(msg) = ctx.event {
- ctx.state.set_error(ctx.conn, msg.to_string_lossy())
+ ctx.state
+ .set_error(ctx.conn, "river", msg.to_string_lossy())
}
}