diff options
| author | Daniel Jankowski <Daniel.Jankowski@rub.de> | 2024-04-16 10:59:15 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-16 10:59:15 +0200 |
| commit | 072392300409c11930cb07f56fab03eda2c24d4a (patch) | |
| tree | a009352ec85fa705d239166873d14ef469b3fbea /src/bin | |
| parent | fix: toggle pane frames with floating panes (diff) | |
| download | sl0pstatus-072392300409c11930cb07f56fab03eda2c24d4a.tar.gz sl0pstatus-072392300409c11930cb07f56fab03eda2c24d4a.tar.xz sl0pstatus-072392300409c11930cb07f56fab03eda2c24d4a.zip | |
feat: remote control zjstatus with pipes (#48)
* chore: update to latest version of zellij
* fix: deprecated functions in chrono
* chore: update nix deps
* chore: remove deprecated chrono functions
* feat: add refresh via pipes with line protocol
* fix: handle multiple lines in pipe
* fix(clippy): char instead of str
* feat: add notification widget
* chore: update nix flake
* chore: update cargo deps
* chore: update cargo deps
* chore: update nix flake
* chore: clean up imports for tracing
* chore: update nix flake
* chore: update cargo deps
* chore: update nix flake
* chore: update cargo deps
* chore: remove pinning of chrono
Since chrono-tz now fixed the deprecations from chrono
we can finally remove the pinning.
* chore: update nix flake
* chore: update cargo deps
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/zjstatus.rs | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/src/bin/zjstatus.rs b/src/bin/zjstatus.rs index 1f0de0e..86cbf70 100644 --- a/src/bin/zjstatus.rs +++ b/src/bin/zjstatus.rs @@ -1,25 +1,20 @@ -use config::ModuleConfig; -use widgets::{ - command::{CommandResult, CommandWidget}, - datetime::DateTimeWidget, - mode::ModeWidget, - session::SessionWidget, - swap_layout::SwapLayoutWidget, - tabs::TabsWidget, - widget::Widget, -}; - -use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; - use zellij_tile::prelude::*; use chrono::Local; -use std::{collections::BTreeMap, fs::File, sync::Arc, usize}; +use std::{collections::BTreeMap, sync::Arc, usize}; use uuid::Uuid; use zjstatus::{ - config::{self, UpdateEventMask, ZellijState}, - frames, widgets, + config::{self, ModuleConfig, UpdateEventMask, ZellijState}, + frames, pipe, + widgets::command::{CommandResult, CommandWidget}, + widgets::datetime::DateTimeWidget, + widgets::mode::ModeWidget, + widgets::notification::NotificationWidget, + widgets::session::SessionWidget, + widgets::swap_layout::SwapLayoutWidget, + widgets::tabs::TabsWidget, + widgets::widget::Widget, }; #[derive(Default)] @@ -36,6 +31,9 @@ register_plugin!(State); #[cfg(feature = "tracing")] fn init_tracing() { + use std::fs::File; + use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; + let file = File::create(".zjstatus.log"); let file = match file { Ok(file) => file, @@ -88,9 +86,34 @@ impl ZellijPlugin for State { sessions: Vec::new(), start_time: Local::now(), cache_mask: 0, + incoming_notification: None, }; } + fn pipe(&mut self, pipe_message: PipeMessage) -> bool { + let mut should_render = false; + + match pipe_message.source { + PipeSource::Cli(_) => { + if let Some(input) = pipe_message.payload { + should_render = pipe::parse_protocol(&mut self.state, &input); + } + } + PipeSource::Plugin(_) => { + if let Some(input) = pipe_message.payload { + should_render = pipe::parse_protocol(&mut self.state, &input); + } + } + PipeSource::Keybind => { + if let Some(input) = pipe_message.payload { + should_render = pipe::parse_protocol(&mut self.state, &input); + } + } + } + + should_render + } + #[tracing::instrument(skip_all, fields(event_type))] fn update(&mut self, event: Event) -> bool { let mut should_render = false; @@ -267,6 +290,10 @@ fn register_widgets(configuration: &BTreeMap<String, String>) -> BTreeMap<String Arc::new(SessionWidget::new(configuration)), ); widget_map.insert("tabs".to_owned(), Arc::new(TabsWidget::new(configuration))); + widget_map.insert( + "notifications".to_owned(), + Arc::new(NotificationWidget::new(configuration)), + ); tracing::debug!("registered widgets: {:?}", widget_map.keys()); |
