### CommandWidget Process Method Example Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/command-widget.md Shows an example of calling the `process` method on a CommandWidget to get rendered output. ```rust let output = widget.process("command_git_branch", &state); // Returns: "#[fg=blue] main " (or equivalent rendered) ``` -------------------------------- ### Working Directory Configuration Example Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/command-widget.md Shows how to specify a custom working directory for command execution. ```text command_name_cwd "/path/to/directory" ``` -------------------------------- ### PipeWidget Constructor Example Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/pipe-widget.md An example demonstrating how to initialize a PipeWidget with specific format and render mode configurations. ```rust use std::collections::BTreeMap; use zjstatus::widgets::pipe::PipeWidget; let mut config = BTreeMap::new(); config.insert( "pipe_my_status_format".to_string(), "#[fg=green] {output} ".to_string() ); config.insert( "pipe_my_status_rendermode".to_string(), "static".to_string() ); let widget = PipeWidget::new(&config); ``` -------------------------------- ### ModeWidget Example Configuration Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/mode-widget.md An example KDL configuration for the ModeWidget, demonstrating how to set custom formats for various modes like Normal, Tmux, Locked, and Resize, as well as a default fallback mode. ```kdl layout { pane { plugin location="zjstatus.wasm" { mode_normal "#[bg=blue,fg=white,bold] NORMAL " mode_tmux "#[bg=#ffc387,fg=black,bold] TMUX " mode_locked "#[bg=red,fg=white,bold] LOCKED " mode_resize "#[bg=yellow,fg=black,bold] RESIZE " mode_pane "#[bg=green,fg=black,bold] PANE " mode_tab "#[bg=cyan,fg=black,bold] TAB " mode_scroll "#[bg=magenta,fg=white,bold] SCROLL " mode_search "#[bg=purple,fg=white,bold] SEARCH " mode_default_to_mode "normal" } } } ``` -------------------------------- ### Full ZJStatus Configuration Example Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/configuration.md An example of a complete ZJStatus configuration within a Zellij layout, demonstrating various widget settings. ```kdl layout { default_tab_template { children pane size=1 borderless=true { plugin location="file:~/zjstatus.wasm" { format_left "{mode} #[fg=#89B4FA,bold]{session}" format_center "{tabs}" format_right "{command_git_branch} {datetime}" format_space "" border_enabled "false" border_char "─" border_format "#[fg=#6C7086]{char}" border_position "top" hide_frame_for_single_pane "true" mode_normal "#[bg=blue] " mode_tmux "#[bg=#ffc387] " tab_normal "#[fg=#6C7086] {name} " tab_active "#[fg=#9399B2,bold,italic] {name} " tab_separator " " datetime "#[fg=#6C7086,bold] {format} " datetime_format "%A, %d %b %Y %H:%M" datetime_timezone "Europe/Berlin" command_git_branch_command "git rev-parse --abbrev-ref HEAD" command_git_branch_format "#[fg=blue] {stdout} " command_git_branch_interval "10" command_git_branch_rendermode "static" } } } } ``` -------------------------------- ### CommandWidget Initialization Example Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/command-widget.md Demonstrates how to initialize a CommandWidget with specific command configurations for Git branch display. ```rust use std::collections::BTreeMap; use zjstatus::widgets::command::CommandWidget; let mut config = BTreeMap::new(); config.insert( "command_git_branch_command".to_string(), "git rev-parse --abbrev-ref HEAD".to_string() ); config.insert( "command_git_branch_format".to_string(), "#[fg=blue] {stdout} ".to_string() ); config.insert( "command_git_branch_interval".to_string(), "10".to_string() ); let widget = CommandWidget::new(&config); ``` -------------------------------- ### Border Styling Examples Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/border-config.md Examples of Zellij's color syntax for border formatting. ```kdl border_format "#[fg=#6C7086]" border_format "#[fg=gray,bold]" border_format "#[fg=#ff0000,bg=#000000]" ``` -------------------------------- ### Environment Variable Configuration Example Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/command-widget.md Illustrates how to configure custom environment variables for a command using KDL format. ```kdl command_name_env { PATH "/custom/path" HOME "/custom/home" } ``` -------------------------------- ### Example: Rendering the Statusbar Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/module-config.md Shows how to call the `render_bar` method to get the statusbar string and print it to the console. This is typically done within a Zellij plugin's rendering loop. ```rust let statusbar = module_config.render_bar(state, widget_map); println!("{}", statusbar); ``` -------------------------------- ### Home Manager Configuration Source: https://github.com/dj95/zjstatus/wiki/1-‐-Installation Example of configuring a Zellij layout using home-manager with the Nix-provided path to the plugin. ```nix xdg.configFile."zellij/layouts/default.kdl".text = ''layout { default_tab_template { children pane size=1 borderless=true { plugin location="file:${pkgs.zjstatus}/bin/zjstatus.wasm" { // plugin configuration... } } } }''; ``` -------------------------------- ### DateTimeWidget Process Method Example Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/datetime-widget.md Example of using the `process` method to render the current time with a specific format and styling. The output is a string that will be rendered by the terminal. ```rust // Config: datetime_format = "%H:%M", datetime = "#[fg=blue] {format} " let output = widget.process("datetime", &state); // Returns: something like "#[fg=blue] 14:30 " (rendered) ``` -------------------------------- ### DateTimeWidget Constructor Example Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/datetime-widget.md An example demonstrating how to initialize a DateTimeWidget with custom datetime format and timezone settings from a BTreeMap configuration. ```rust use std::collections::BTreeMap; use zjstatus::widgets::datetime::DateTimeWidget; let mut config = BTreeMap::new(); config.insert("datetime_format".to_string(), "%A, %d %b %Y %H:%M".to_string()); config.insert("datetime_timezone".to_string(), "Europe/Berlin".to_string()); config.insert("datetime".to_string(), "#[fg=#6C7086,bold] {format} ".to_string()); let widget = DateTimeWidget::new(&config); ``` -------------------------------- ### Example: Creating FrameConfig Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/frame-config.md Demonstrates how to instantiate FrameConfig with specific settings, in this case, enabling frame hiding for a single pane. ```rust let config = FrameConfig::new(true, false, false, false); // Hide frames only for single pane ``` -------------------------------- ### TabsWidget process() Method Example Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/tabs-widget.md Illustrates the expected output format of the process() method when rendering the tab bar. This example shows a typical string representation of tabs. ```rust let output = widget.process("tabs", &state); // Returns something like: // " [1] foo | [2] bar | [3] baz " // where [2] is highlighted as active ``` -------------------------------- ### FormattedPart Example: Simple Formatting Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/formatted-part.md Demonstrates creating a FormattedPart with a blue foreground color and 'Hello' content. ```rust let part1 = FormattedPart::from_format_string("#[fg=blue]Hello", &config); // fg: Some(blue), content: "Hello" ``` -------------------------------- ### Example: Creating ModuleConfig Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/module-config.md Demonstrates how to initialize a ModuleConfig by inserting configuration options into a BTreeMap and calling the `new` constructor. This is useful for setting up the statusbar's appearance and behavior. ```rust use std::collections::BTreeMap; use zjstatus::config::ModuleConfig; let mut config = BTreeMap::new(); config.insert("format_left".to_string(), "{mode} #{session}".to_string()); config.insert("format_center".to_string(), "{tabs}".to_string()); config.insert("format_right".to_string(), "{datetime}".to_string()); config.insert("format_space".to_string(), " ".to_string()); config.insert("hide_frame_for_single_pane".to_string(), "true".to_string()); let module_config = ModuleConfig::new(&config)?; ``` -------------------------------- ### Widget Registration Example Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/widget-trait.md Illustrates how widgets are registered using a BTreeMap, allowing for lookup by name and routing of events. ```rust use std::sync::Arc; use std::collections::BTreeMap; use zjstatus::widgets::widget::Widget; let mut widget_map: BTreeMap> = BTreeMap::new(); widget_map.insert( "mode".to_string(), Arc::new(ModeWidget::new(&config)) ); widget_map.insert( "tabs".to_string(), Arc::new(TabsWidget::new(&config)) ); ``` -------------------------------- ### FormattedPart Example: Plain Text Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/formatted-part.md Illustrates creating a FormattedPart with no formatting, only plain text content. ```rust let part3 = FormattedPart::from_format_string("plain text", &config); // No formatting, content: "plain text" ``` -------------------------------- ### PipeWidget process() Method Example Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/pipe-widget.md Illustrates how the `process` method renders piped data based on configuration, replacing the {output} placeholder. ```rust // With piped data: "active" // Config: pipe_status_format = "#[fg=green] {output} " let output = widget.process("pipe_status", &state); // Returns: rendered string with "active" in green ``` -------------------------------- ### ModeWidget Constructor Example Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/mode-widget.md Demonstrates how to create a ModeWidget by providing a configuration map with custom formats for 'mode_normal', 'mode_tmux', and 'mode_tab'. ```rust use std::collections::BTreeMap; use zjstatus::widgets::mode::ModeWidget; let mut config = BTreeMap::new(); config.insert("mode_normal".to_string(), "#[bg=blue] NORMAL ".to_string()); config.insert("mode_tmux".to_string(), "#[bg=orange] TMUX ".to_string()); config.insert("mode_tab".to_string(), "#[bg=green] TAB ".to_string()); let widget = ModeWidget::new(&config); ``` -------------------------------- ### Example Widget Implementation Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/widget-trait.md A sample implementation of the Widget trait, demonstrating how to process state to render output and handle clicks. ```rust use zjstatus::widgets::widget::Widget; use zjstatus::config::ZellijState; pub struct ExampleWidget { format: String, } impl Widget for ExampleWidget { fn process(&self, name: &str, state: &ZellijState) -> String { format!("Example Output: {}", state.cols) } fn process_click(&self, name: &str, state: &ZellijState, pos: usize) { // Handle click } } ``` -------------------------------- ### TabsWidget Configuration Example Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/tabs-widget.md Demonstrates how to configure the TabsWidget by inserting various settings into a BTreeMap. This includes tab formatting, separators, and display options. ```rust use std::collections::BTreeMap; use zjstatus::widgets::tabs::TabsWidget; let mut config = BTreeMap::new(); config.insert("tab_active".to_string(), "#[fg=white,bold] {name} ".to_string()); config.insert("tab_normal".to_string(), " {name} ".to_string()); config.insert("tab_separator".to_string(), "|".to_string()); config.insert("tab_display_count".to_string(), "20".to_string()); let widget = TabsWidget::new(&config); ``` -------------------------------- ### Multiple Pipe Displays Configuration Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/pipe-widget.md KDL layout example showing how to integrate multiple pipe widgets into the status bar, alongside other format elements. ```kdl layout { pane { plugin location="zjstatus.wasm" { format_left "{mode} #[fg=cyan]{hostname}" format_center "{tabs}" format_right "{pipe_status} {pipe_time} {datetime}" pipe_status_format "#[fg=green] {output} " pipe_time_format "#[fg=yellow] {output} " } } } ``` -------------------------------- ### FormattedPart Example: Applying Style to Content Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/formatted-part.md Shows how to use the format_string method to apply pre-defined styling to a text string. ```rust let part = FormattedPart::from_format_string("#[fg=blue,bold]", &config); let output = part.format_string("Hello"); // Returns: ANSI codes for blue + bold, "Hello", ANSI reset ``` -------------------------------- ### FormattedPart Example: Complex Formatting Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/formatted-part.md Shows creating a FormattedPart with specific foreground, background, and bold effect. ```rust let part2 = FormattedPart::from_format_string("#[fg=#ff0000,bg=#000000,bold]ERROR", &config); // fg: Some(red), bg: Some(black), bold: true, content: "ERROR" ``` -------------------------------- ### FormattedPart Example: Multiple Parts Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/formatted-part.md Demonstrates parsing a string into a vector of FormattedPart instances, each with its own styling. ```rust let parts = FormattedPart::multiple_from_format_string( "#[fg=blue]left#[fg=red]right", &config ); // Returns: [ // FormattedPart { fg: blue, content: "left" }, // FormattedPart { fg: red, content: "right" } // ] ``` -------------------------------- ### Example Pipe Messages Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/pipe-widget.md Provides examples of messages that can be sent to different pipes within the zjstatus pipe protocol. ```plaintext zjstatus::pipe::git_status::modified zjstatus::pipe::battery::85% zjstatus::pipe::host::myserver ``` -------------------------------- ### Example: Handling a Mouse Click Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/module-config.md Illustrates how to simulate a mouse click event and pass it to the `handle_mouse_action` method for processing. This is used to make statusbar elements interactive. ```rust use zellij_tile::prelude::Mouse; let click = Mouse::LeftClick(5, 0); module_config.handle_mouse_action(state, click, widget_map); ``` -------------------------------- ### Shell Script Integration for Pipe Updates Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/pipe-widget.md Example bash scripts demonstrating how to continuously update pipe widgets for battery and weather status. ```bash #!/bin/bash # Update battery status every 30 seconds while true; do battery=$(acpi -b | grep -oP '\d+(?=%))') echo "zjstatus::pipe::battery::${battery}%" | zellij pipe sleep 30 done & # Update weather every 10 minutes while true; do weather=$(curl -s wttr.in?format=3 | cut -d' ' -f1,2) echo "zjstatus::pipe::weather::${weather}" | zellij pipe sleep 600 done & ``` -------------------------------- ### Configure Git Branch and Memory Widgets Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/command-widget.md Example KDL configuration for setting up Git branch and memory usage widgets. This snippet shows how to define commands, output formats, update intervals, and rendering modes for custom widgets. ```kdl layout { pane { plugin location="zjstatus.wasm" { command_git_branch_command "git rev-parse --abbrev-ref HEAD" command_git_branch_format "#[fg=blue] {stdout} " command_git_branch_interval "10" command_git_branch_rendermode "static" command_git_branch_clickaction "zellij action NewTab" command_memory_command "free -h | awk 'NR==2 {print $3}'" command_memory_format "#[fg=yellow] MEM {stdout} " command_memory_interval "5" command_memory_hideonemptystdout "false" } } } ``` -------------------------------- ### Enable Zero-Based Tab Indexing Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/configuration.md Changes the tab numbering in the `{index}` placeholder to start from 0 instead of 1. Set to 'true' to enable. ```kdl tab_zero_based_index "true" ``` -------------------------------- ### System Status Display Configuration Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/pipe-widget.md An example KDL configuration for displaying system status information like battery and weather using PipeWidgets. ```kdl layout { pane { plugin location="zjstatus.wasm" { pipe_battery_format "#[fg=red] {output} " pipe_battery_rendermode "static" pipe_weather_format "#[fg=cyan] {output} " pipe_weather_rendermode "static" pipe_vpn_format "#[fg=green] VPN:{output} " pipe_vpn_rendermode "static" } } } ``` -------------------------------- ### Define Vertical Swap Layout in Separate File Source: https://github.com/dj95/zjstatus/wiki/3-‐-Configuration This example shows how to define a named vertical swap layout in a separate KDL file, indicated by the `.swap.kdl` extension. ```diff +swap_tiled_layout name="vertical" { + tab max_panes=5 { + pane split_direction="vertical" { + pane + pane { children; } + } + } + tab max_panes=8 { + pane split_direction="vertical" { + pane { children; } + pane { pane; pane; pane; pane; } + } + } + tab max_panes=12 { + pane split_direction="vertical" { + pane { children; } + pane { pane; pane; pane; pane; } + pane { pane; pane; pane; pane; } + } + } +} ``` -------------------------------- ### Minimal Zellij Status Bar Setup Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/QUICK_REFERENCE.md This configuration sets up a basic status bar with left, center, and right sections displaying mode, tabs, and datetime respectively. Ensure the plugin path is correct. ```kdl plugin location="file:~/zjstatus.wasm" { format_left "{mode}" format_center "{tabs}" format_right "{datetime}" } ``` -------------------------------- ### Status Mode Styling Example Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/formatted-part.md Shows how to create a FormattedPart for error messages with red foreground and bold text. The `format_string` method is used to render the final output. ```rust let error_format = FormattedPart::from_format_string( "#[fg=#ff0000,bold]ERROR", &config ); let error_output = error_format.format_string("ERROR: Invalid config"); ``` -------------------------------- ### Install zjframes Plugin via File or URL Source: https://github.com/dj95/zjstatus/wiki/6---zjframes Configure zjframes to load as a background plugin. Specify the path to the plugin file or its URL. Options for frame visibility can be set within the plugin's configuration block. ```javascript // Plugins to load in the background when a new session starts load_plugins { "file:./path/to/zjframes.wasm" { hide_frame_for_single_pane "false" hide_frame_except_for_search "true" hide_frame_except_for_fullscreen "true" } // or "https://github.com/dj95/zjstatus/releases/latest/download/zjframes.wasm" { hide_frame_for_single_pane "false" hide_frame_except_for_search "true" hide_frame_except_for_fullscreen "true" } } ``` -------------------------------- ### Send Notify Command from Shell Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/pipe-protocol.md Example of sending a notification command to indicate a build failure using `echo` and `zellij pipe`. ```bash echo "zjstatus::notify::Build failed!" | zellij pipe ``` -------------------------------- ### Configure zjstatus in Zellij Layout Source: https://github.com/dj95/zjstatus/blob/main/README.md Add this configuration to your default layout file. Grant permissions when prompted by Zellij after starting. ```javascript layout { default_tab_template { children pane size=1 borderless=true { plugin location="https://github.com/dj95/zjstatus/releases/latest/download/zjstatus.wasm" { format_left "{mode} #[fg=#89B4FA,bold]{session}" format_center "{tabs}" format_right "{command_git_branch} {datetime}" format_space "" border_enabled "false" border_char "─" border_format "#[fg=#6C7086]{char}" border_position "top" hide_frame_for_single_pane "true" mode_normal "#[bg=blue] " mode_tmux "#[bg=#ffc387] " tab_normal "#[fg=#6C7086] {name} " tab_active "#[fg=#9399B2,bold,italic] {name} " command_git_branch_command "git rev-parse --abbrev-ref HEAD" command_git_branch_format "#[fg=blue] {stdout} " command_git_branch_interval "10" command_git_branch_rendermode "static" datetime "#[fg=#6C7086,bold] {format} " datetime_format "%A, %d %b %Y %H:%M" datetime_timezone "Europe/Berlin" } } } } ``` -------------------------------- ### Send Pipe Command from Shell Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/pipe-protocol.md Example of sending a pipe command to update the battery widget using `echo` and `zellij pipe`. ```bash echo "zjstatus::pipe::battery::85%" | zellij pipe ``` -------------------------------- ### Command Widget Example: Git Branch Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/QUICK_REFERENCE.md Configure a command widget to display the current Git branch. It specifies the command to run, the format for displaying the output, the refresh interval, rendering mode, and a click action. ```kdl command_git_branch_command "git rev-parse --abbrev-ref HEAD" command_git_branch_format "#[fg=blue] {stdout} " command_git_branch_interval "10" // Seconds between runs command_git_branch_rendermode "static" // static|dynamic|raw command_git_branch_clickaction "zellij action NewTab" ``` -------------------------------- ### Example: Using is_disabled() Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/frame-config.md Illustrates checking if a FrameConfig is disabled (no hiding options active) and if it's active (at least one hiding option enabled). ```rust let config = FrameConfig::new(false, false, false, false); assert!(config.is_disabled()); let config2 = FrameConfig::new(true, false, false, false); assert!(!config2.is_disabled()); ``` -------------------------------- ### Tabs Widget Configuration Example Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/tabs-widget.md This KDL configuration defines the appearance and behavior of the tabs widget, including normal and active tab formats, fullscreen indicators, and notification symbols. ```kdl layout { pane { plugin location="zjstatus.wasm" { tab_normal " {index} {name} " tab_active "#[fg=white,bold,bg=blue] {index} {name} " tab_normal_fullscreen " {index} F:{name} " tab_active_fullscreen "#[fg=white,bold,bg=blue] {index} F:{name} " tab_separator "#[fg=gray] | " tab_bell_indicator "!" tab_flashing_bell_indicator "!!" tab_display_count "20" tab_truncate_start_format "#[fg=gray] ... " tab_truncate_end_format " ... " tab_zero_based_index "false" } } } ``` -------------------------------- ### Sending Battery Status via Pipe Protocol Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/INDEX.md An external script example that fetches battery status using `acpi` and sends it to Zellij via the pipe protocol. This demonstrates real-time data integration from external processes. ```bash # Send battery status via pipe protocol while true; do battery=$(acpi -b | grep -oP '\d+(?=%))') echo "zjstatus::pipe::battery::${battery}%" | zellij pipe sleep 30 done ``` -------------------------------- ### Conditional Styling Example Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/formatted-part.md Demonstrates how to apply different styles based on a boolean condition. Active status uses white bold text, while inactive uses gray text. ```rust let format_string = if is_active { "#[fg=white,bold]Active" } else { "#[fg=gray]Inactive" }; let part = FormattedPart::from_format_string(format_string, &config); ``` -------------------------------- ### Multiple Timezone Display Configuration (Conceptual) Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/datetime-widget.md This example demonstrates the desired output for displaying multiple timezones, but note that the DateTimeWidget only supports one timezone per instance. Achieving this would require multiple widget instances or custom command widgets. ```kdl layout { pane { plugin location="zjstatus.wasm" { datetime_format "{format}" datetime_timezone "Europe/Berlin" datetime "#[fg=cyan] NY:{time_ny} BER:{time_ber} " } } } ``` -------------------------------- ### Full Widget Configuration with Styling Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/remaining-widgets.md Demonstrates a comprehensive widget configuration with styled modes for normal and tmux, including a fallback to normal mode. ```kdl format_left "{mode}" mode_normal "#[bg=blue,fg=white,bold] NORMAL " mode_tmux "#[bg=#ffc387] TMUX " mode_default_to_mode "normal" ``` -------------------------------- ### Configure Tab Separator Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/configuration.md Defines the separator string displayed between tabs. This example uses a gray vertical bar. ```kdl tab_separator "#[fg=gray] | " ``` -------------------------------- ### Invalid Protocol Messages Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/pipe-protocol.md Examples of messages that are silently ignored by the protocol parser due to incorrect formatting or unknown commands. ```text zjstatus::unknown::arg # Unknown command zjstatus::pipe::only_two # Pipe requires 3 args zjstatus::notify # No message invalid::notify::msg # Wrong prefix ``` -------------------------------- ### Pipe Widget Configuration Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/QUICK_REFERENCE.md Configure how the output from a pipe is displayed in the status bar. The `{output}` placeholder is used to show the received data. ```kdl # In configuration pipe_status_format "#[fg=green] {output} " ``` -------------------------------- ### Configure Swap Layout Format Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/configuration.md Defines the format for displaying the swap layout name. Uses the {name} placeholder. ```kdl swap_layout_format "#[fg=cyan] {name} " ``` -------------------------------- ### Minimal Widget Configuration Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/remaining-widgets.md Provides a basic configuration for a widget, displaying the mode in the 'format_left' and setting a simple string for the normal mode. ```kdl format_left "{mode}" mode_normal "NORMAL" ``` -------------------------------- ### Send Rerun Command from Shell Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/pipe-protocol.md Example of sending a rerun command to immediately re-execute the `git_branch` command using `echo` and `zellij pipe`. ```bash # Re-run git_branch command immediately echo "zjstatus::rerun::git_branch" | zellij pipe ``` -------------------------------- ### process() Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/command-widget.md Renders the command output in the configured format. It checks the execution interval, retrieves cached results, formats the output, and applies styling based on the render mode. Returns an empty string if the command has not yet executed or if configured to hide on empty stdout. ```APIDOC ## process() ### Description Renders the command output in the configured format. ### Behavior 1. Checks if command needs to run (interval check) 2. Retrieves cached command result from state 3. Formats output according to configuration 4. Applies color/style based on render mode ### Placeholders in Format String - `{exit_code}` - Exit code of the command (-1 if no result yet) - `{stdout}` - Standard output of the command (newline stripped) - `{stderr}` - Standard error output (newline stripped) ### Returns Empty string if command not yet executed or if `hide_on_empty_stdout` is true and stdout is empty. ### Example ```rust let output = widget.process("command_git_branch", &state); // Returns: "#[fg=blue] main " (or equivalent rendered) ``` ``` -------------------------------- ### Statusbar Configuration with Git Branch Command Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/INDEX.md Extends basic configuration to include a git branch command, defining its execution, format, and interval. This snippet demonstrates how to integrate dynamic command output into the statusbar. ```kdl plugin location="file:~/zjstatus.wasm" { format_left "{mode} {session}" format_center "{tabs}" format_right "{command_git} {datetime}" command_git_command "git rev-parse --abbrev-ref HEAD" command_git_format "#[fg=blue] {stdout} " command_git_interval "10" } ``` -------------------------------- ### Configure Truncation Indicator at Start Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/configuration.md Specifies the format for the truncation indicator when tabs are hidden at the beginning. Uses `{count}` for the number of hidden tabs. ```kdl tab_truncate_start_format "#[fg=gray] ... " ``` -------------------------------- ### DateTimeWidget Constructor Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/datetime-widget.md Shows how to create a new DateTimeWidget instance using a configuration map. ```rust pub fn new(config: &BTreeMap) -> Self ``` -------------------------------- ### Basic Statusbar Configuration Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/INDEX.md A minimal configuration for the Zellij statusbar using the plugin location and basic format strings for left, center, and right sections. ```kdl plugin location="file:~/zjstatus.wasm" { format_left "{mode} {session}" format_center "{tabs}" format_right "{datetime}" } ``` -------------------------------- ### Set Border Format Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/configuration.md Apply styling to the border character using Zellij's color syntax. Examples include setting foreground color and boldness. ```kdl border_format "#[fg=#6C7086]" ``` ```kdl border_format "#[fg=#89B4FA,bold]" ``` -------------------------------- ### Widget-Specific Placeholders Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/QUICK_REFERENCE.md Specific widgets support additional placeholders for more granular control over displayed information. For example, the datetime widget supports format, date, and time placeholders. ```plaintext mode: {name} tabs: {name}, {index} datetime: {format}, {date}, {time} command: {stdout}, {stderr}, {exit_code} pipe: {output} notification: {message} swap_layout: {name} ``` -------------------------------- ### Manual Layout Configuration Source: https://github.com/dj95/zjstatus/wiki/1-‐-Installation Reference a locally downloaded .wasm binary in your layout file using a file path. ```javascript layout { default_tab_template { children pane size=1 borderless=true { plugin location="file:~/path/to/zjstatus.wasm" { // plugin configuration... } } } } ``` -------------------------------- ### Pipe Protocol: Sending Data from Shell Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/QUICK_REFERENCE.md Example of sending data to the zjstatus plugin via the `zellij pipe` command from the shell. This updates a specified pipe widget. ```bash # From shell echo "zjstatus::pipe::my_pipe::status" | zellij pipe ``` -------------------------------- ### Render Status Using ZellijState Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/zellij-state.md Example of how to use ZellijState within a widget to render status information like session name, tab count, and terminal width. ```rust use zjstatus::config::ZellijState; fn render_status(state: &ZellijState) -> String { format!( "Session: {}, Tabs: {}, Width: {}", state.mode.session_name.as_ref().unwrap_or(&"unnamed".to_string()), state.tabs.len(), state.cols ) } ``` -------------------------------- ### Send Notification on Event via Pipe Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/pipe-protocol.md This example demonstrates sending a notification message to Zellij after a long-running command successfully completes. The 'long_running_command' should be replaced with the actual command. ```bash #!/bin/bash # Send notification when command finishes long_running_command && echo "zjstatus::notify::Command completed!" | zellij pipe ``` -------------------------------- ### Configure Pipe Output Format Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/configuration.md Defines the format for displaying piped data. Supports the {output} placeholder. ```kdl pipe_battery_format "#[fg=red] {output} " ``` -------------------------------- ### Set Resize Mode Format Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/configuration.md Configure the format string for the Resize mode display in the statusbar. ```kdl mode_resize "" ``` -------------------------------- ### Sending Data to Pipe via Shell Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/pipe-widget.md Demonstrates how to send data to a specific pipe using the `zellij pipe` command in a shell environment. ```bash echo "zjstatus::pipe::my_pipe::hello world" | zellij pipe ``` -------------------------------- ### Module Config API Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/INDEX.md Provides methods for configuring and rendering the statusbar, as well as handling mouse interactions. ```APIDOC ## Module Config API ### Description Provides methods for configuring and rendering the statusbar, as well as handling mouse interactions. ### Methods - `new()`: Constructor for the main configuration struct. - `render_bar()`: Renders the complete statusbar. - `handle_mouse_action()`: Handles click events on the statusbar. ``` -------------------------------- ### Configure zjframes Plugin with URL Source: https://github.com/dj95/zjstatus/wiki/6---zjframes Load the zjframes plugin from a remote URL and configure its frame hiding behavior. This example demonstrates hiding frames except for search and fullscreen modes. ```javascript // Plugins to load in the background when a new session starts load_plugins { "https://github.com/dj95/zjstatus/releases/latest/download/zjframes.wasm" { hide_frame_for_single_pane "false" hide_frame_except_for_search "true" hide_frame_except_for_fullscreen "true" } } ``` -------------------------------- ### Send Battery Status Update via Pipe Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/pipe-protocol.md This script continuously monitors battery percentage and sends updates to Zellij using the pipe protocol. It requires the 'acpi' command to be installed. ```bash #!/bin/bash while true; do battery=$(acpi -b | grep -oP '\d+(?=%))') echo "zjstatus::pipe::battery::${battery}%" | zellij pipe sleep 30 done ``` -------------------------------- ### Configure Click Action Command Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/configuration.md Defines a shell command to be executed when the widget is clicked. Useful for triggering actions. ```kdl command_git_branch_clickaction "zellij action NewTab" ``` -------------------------------- ### Add Vertical Swap Layout to Layout Configuration Source: https://github.com/dj95/zjstatus/wiki/3-‐-Configuration This example shows how to add a named vertical swap layout directly within the main Zellij layout configuration file using diff syntax. ```diff layout { + swap_tiled_layout name="vertical" { + tab max_panes=5 { + pane split_direction="vertical" { + pane + pane { children; } + } + } + tab max_panes=8 { + pane split_direction="vertical" { + pane { children; } + pane { pane; pane; pane; pane; } + } + } + tab max_panes=12 { + pane split_direction="vertical" { + pane { children; } + pane { pane; pane; pane; pane; } + pane { pane; pane; pane; pane; } + } + } + } default_tab_template { children pane size=1 borderless=true { plugin location="https://github.com/dj95/zjstatus/releases/latest/download/zjstatus.wasm" { // plugin configuration... } } } } ``` -------------------------------- ### CommandWidget::new() Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/command-widget.md Creates a new CommandWidget instance from a configuration map. The configuration keys define the behavior of individual commands, including the command to execute, output formatting, execution interval, and click actions. ```APIDOC ## CommandWidget::new() ### Description Creates a new CommandWidget from configuration. ### Method `CommandWidget::new(config: &BTreeMap) -> Self` ### Parameters #### Path Parameters - **config** (`&BTreeMap`) - Required - Full plugin configuration from Zellij ### Configuration Keys - `command_my_command_command` - Shell command to execute - `command_my_command_format` - Format string for output (supports `{exit_code}`, `{stdout}`, `{stderr}`) - `command_my_command_interval` - Execution interval in seconds (default: 1) - `command_my_command_rendermode` - "static", "dynamic", or "raw" (default: "static") - `command_my_command_clickaction` - Shell command to run on click - `command_my_command_env` - KDL environment variables configuration - `command_my_command_cwd` - Working directory for command execution - `command_my_command_hideonemptystdout` - "true" to hide widget when command produces no output ### Request Example ```rust use std::collections::BTreeMap; use zjstatus::widgets::command::CommandWidget; let mut config = BTreeMap::new(); config.insert( "command_git_branch_command".to_string(), "git rev-parse --abbrev-ref HEAD".to_string() ); config.insert( "command_git_branch_format".to_string(), "#[fg=blue] {stdout} ".to_string() ); config.insert( "command_git_branch_interval".to_string(), "10".to_string() ); let widget = CommandWidget::new(&config); ``` ``` -------------------------------- ### Widget Integration with Multiple Formats Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/formatted-part.md Shows how widgets can parse format strings into multiple FormattedParts during initialization. The `format_string` method is then used to render content, with parsing done once for efficiency. ```rust let format = FormattedPart::multiple_from_format_string( "#[fg=blue]Mode: {name}", &config ); // Later, during render: let content = format.iter() .map(|f| f.format_string(&f.content)) .collect::(); ``` -------------------------------- ### SwapLayoutWidget Constructor with Configuration Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/remaining-widgets.md Initializes a SwapLayoutWidget, setting the format for layout names and whether to hide the widget when no swap layout is active. ```rust pub fn new(config: &BTreeMap) -> Self ``` ```rust let mut config = BTreeMap::new(); config.insert( "swap_layout_format".to_string(), "#[fg=cyan] {name} ".to_string() ); config.insert( "swap_layout_hide_if_empty".to_string(), "true".to_string() ); let widget = SwapLayoutWidget::new(&config); ``` -------------------------------- ### Zellij Status Bar with Commands and Pipes Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/QUICK_REFERENCE.md This configuration integrates command output and piped data into the status bar. Ensure command intervals are set appropriately (e.g., 0 for one-time execution) and pipe names match configuration keys. ```kdl plugin location="file:~/zjstatus.wasm" { format_left "{mode} {session}" format_center "{tabs}" format_right "{command_git} {pipe_battery} {datetime}" command_git_command "git rev-parse --abbrev-ref HEAD" command_git_format "#[fg=blue] {stdout} " command_git_interval "5" pipe_battery_format "#[fg=red] {output} " datetime_format "%H:%M" } ``` -------------------------------- ### zjstatus Display Format Options Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/QUICK_REFERENCE.md Configure the alignment and content of the left, center, and right sections of the status bar, and how to fill the space between them. ```kdl format_left "..." // Left-aligned section format_center "..." // Centered section format_right "..." // Right-aligned section format_space " " // Fill between sections ``` -------------------------------- ### Configure Command Widget Source: https://github.com/dj95/zjstatus/wiki/4-‐-Widgets Defines how to execute arbitrary commands, format their output, set intervals, and manage rendering modes. Use this for dynamic command execution within ZJStatus. ```javascript // the command that should be executed command_NAME_command "bash -c \"pwd | base64\"" // themeing and format of the command command_NAME_format "#[fg=blue, bg=black] {exit_code} {stdout} {stderr}" // interval in seconds, between two command runs // // Set to "0" for running the command once. Only non-negative integers are allowed. command_NAME_interval "1" // render mode of the command. ["static", "dynamic", "raw"] // // "static" :: format the command with the given format from the config and don't // consider any other formatting directives // "dynamic" :: format the command based on the command output. When the command // output contains formatting strings for zjstatus, zjstatus will // try to render them. This might lead to unexpected behavior, in case // the formatting is not correct. // "raw" :: do not apply any formatting. This can be used to properly render // ansi escape sequences from the command output. command_NAME_rendermode "static" // set an absolute path as cwd where the command should be executed command_NAME_cwd "/Users/daniel" // specify environment variables that are set when running the command command_NAME_env { FOO "1" BAR "foo" } ``` -------------------------------- ### Placeholder Syntax in Format Strings Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/QUICK_REFERENCE.md These placeholders can be used within format strings to display dynamic information in the status bar. Examples include current input mode, session name, tabs, date and time, command results, piped data, notifications, and swap layout names. ```plaintext {mode} {session} {tabs} {datetime} {command_NAME} {pipe_NAME} {notifications} {swap_layout} ``` -------------------------------- ### Configure DateTime Display Format Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/configuration.md Sets the overall styling format for the datetime output. Supports `{format}`, `{date}`, and `{time}` placeholders. ```kdl datetime "#[fg=#6C7086,bold] {format} " ``` -------------------------------- ### NotificationWidget Constructor with Configuration Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/remaining-widgets.md Creates a NotificationWidget, configuring notification display formats and intervals. ```rust pub fn new(config: &BTreeMap) -> Self ``` ```rust let mut config = BTreeMap::new(); config.insert( "notification_format_unread".to_string(), "#[fg=red] {message} ".to_string() ); config.insert( "notification_show_interval".to_string(), "3".to_string() ); let widget = NotificationWidget::new(&config); ``` -------------------------------- ### zjstatus Date and Time Configuration Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/QUICK_REFERENCE.md Set the format and timezone for displaying the date and time in the status bar. Uses strftime for time formatting and IANA for timezones. ```kdl datetime "#[fg=blue] {format} " // Formatting datetime_format "%H:%M" // Time format (strftime) datetime_timezone "Europe/Berlin" // Timezone (IANA) ``` -------------------------------- ### Color Syntax in Format Strings Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/QUICK_REFERENCE.md Demonstrates how to apply colors and text effects (bold, italic, etc.) within zjstatus format strings using a simple syntax. ```string #[fg=red] // Named color (foreground) #[bg=blue] // Named color (background) #[fg=#ff0000] // Hex color #[bold] // Effect: bold, italic, underline, strikethrough, etc. #[fg=blue,bg=white,bold] // Combined ``` -------------------------------- ### Simple Border Configuration Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/border-config.md Enables a simple border with a specified character and position. ```kdl layout { pane { plugin location="zjstatus.wasm" { border_enabled "true" border_char "─" border_position "top" } } } ``` -------------------------------- ### Configure Command Environment Variables Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/configuration.md Sets environment variables for the command execution in KDL format. Allows customization of the command's execution context. ```kdl command_git_branch_env { PATH "/custom/path" HOME "/custom/home" } ``` -------------------------------- ### Set Primary Datetime Format String Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/configuration.md Defines the main format for displaying date and time using strftime syntax. The default is '%H:%M'. ```kdl datetime_format "%A, %d %b %Y %H:%M" ``` -------------------------------- ### CommandWidget Constructor Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/api-reference/command-widget.md Creates a new CommandWidget instance using provided configuration. ```rust pub fn new(config: &BTreeMap) -> Self> ``` -------------------------------- ### Minimalist ZJStatus Style Source: https://github.com/dj95/zjstatus/blob/main/_autodocs/QUICK_REFERENCE.md Minimalist configuration for ZJStatus display formats. ```kdl format_left "{mode}" format_center "{tabs}" format_right "{datetime}" ```