2.6 KiB
2.6 KiB
Zellij Socktop Plugin
A Zellij plugin that displays real-time system metrics from a socktop agent.
Quick Start
-
Build the plugin:
cargo build --target wasm32-wasi --release -
Install in Zellij:
# Copy the WASM file to Zellij plugins directory mkdir -p ~/.config/zellij/plugins cp target/wasm32-wasi/release/zellij_socktop_plugin.wasm ~/.config/zellij/plugins/socktop.wasm cp plugin.yaml ~/.config/zellij/plugins/ -
Use in Zellij layout:
# ~/.config/zellij/layouts/socktop.yaml template: direction: Horizontal parts: - direction: Vertical borderless: true split_size: Fixed: 1 run: plugin: location: "file:~/.config/zellij/plugins/socktop.wasm" configuration: server_url: "ws://localhost:3000/ws" - direction: Vertical -
Launch Zellij with the layout:
zellij --layout socktop
Plugin Features
- Real-time Metrics: Displays CPU and memory usage
- Auto-refresh: Updates every 2 seconds
- Reconnection: Press 'r' to reconnect to socktop agent
- Configurable: Set custom server URL in plugin config
- Error Handling: Shows connection status and errors
Configuration Options
server_url: WebSocket URL for socktop agent (default:ws://localhost:3000/ws)
Controls
r- Reconnect to socktop agent- Plugin updates automatically every 2 seconds
Development Notes
This is a scaffold implementation. To make it fully functional:
-
Async Operations: Zellij plugins have limitations with async operations. You may need to:
- Use a different async runtime or approach
- Handle WebSocket connections in a background thread
- Use message passing between threads
-
Error Handling: Add more robust error handling for:
- Network connectivity issues
- Invalid server URLs
- Agent unavailability
-
UI Improvements:
- Add more detailed metrics display
- Implement scrolling for large datasets
- Add color coding for status indicators
-
Performance:
- Implement caching to reduce agent requests
- Add configurable update intervals
- Optimize WASM binary size
Dependencies
zellij-tile: Zellij plugin frameworksocktop_connector: WebSocket connector with WASM supportserde: JSON serializationchrono: Time handling (WASM-compatible)
Building
# Add WASM target
rustup target add wasm32-wasi
# Build for WASM
cargo build --target wasm32-wasi --release
# The plugin will be at: target/wasm32-wasi/release/zellij_socktop_plugin.wasm