Overview
The IPC system provides:- Query Compositor State: Get information about windows, tags, layouts, and monitors
- Send Commands: Control the compositor programmatically
- Scripting Support: Build custom automation and workflows
- External Tools: Integrate with status bars, launchers, and utilities
- Real-time Updates: React to compositor events
IPC Protocol
Mango’s IPC is based on the dwl-ipc protocol, providing a stable interface for external communication.Protocol File
The IPC protocol is defined in:- Subscribe to compositor events
- Query current state
- Send commands to the compositor
Using IPC
IPC Socket
Mango creates an IPC socket that clients connect to for communication. The socket location typically follows XDG standards:IPC Clients
To interact with Mango via IPC, you need an IPC client:- Direct Socket Communication: Write your own client using Unix sockets
- Existing Tools: Use compatible tools from dwl ecosystem
- Status Bar Integration: Many status bars support dwl-ipc protocol
IPC Commands
While specific command syntax requires checking the protocol definition, typical IPC capabilities include:Query Commands
List Windows
Get information about all open windows
Current Tag
Query which tag is currently active
Layout Info
Get current layout name and configuration
Monitor Status
Query connected monitors and their state
Control Commands
Change Layout
Switch to a specific layout programmatically
Focus Window
Focus a specific window by ID
Move Window
Move windows between tags or monitors
Execute Actions
Trigger compositor actions from external scripts
Status Bar Integration
Waybar
Waybar can integrate with Mango via IPC to display compositor information:Specific Waybar module configuration for Mango may require the
wlr/workspaces module or a dwl-specific module. Check Waybar documentation for details.Other Status Bars
Status bars with dwl-ipc support:- Waybar: Via wlr/workspaces or custom modules
- eww: Via custom IPC scripts
- AGS: Via JavaScript IPC bindings
- yambar: Via custom IPC integration
Scripting with IPC
Example Use Cases
Automated Layout Switching
Automated Layout Switching
Switch layouts based on time of day, number of windows, or other conditions.
Window Management Scripts
Window Management Scripts
Create custom window management commands.
Monitor Configuration
Monitor Configuration
Automatically adjust layout when monitor configuration changes.
Status Updates
Status Updates
Feed compositor state to other applications.
Building IPC Clients
Socket Communication
IPC clients connect to Mango’s Unix socket:Protocol Details
Language Bindings
Consider creating language bindings for easier IPC usage:- Python: High-level wrapper around socket communication
- JavaScript: For integration with AGS or other JS tools
- Shell Scripts: Simple wrapper scripts for common operations
- Rust/Go: Type-safe bindings for robust tools
IPC Event Subscription
IPC clients can subscribe to compositor events:Event Types
Fired when a new window is opened
Fired when a window is closed
Fired when active tag changes
Fired when layout is switched
Fired when window focus changes
Subscribing to Events
Integration Examples
Custom Tag Switcher
Build a graphical tag switcher:Window Selector
Create a window selector that works across all tags:Layout Indicator
Display current layout in status bar:IPC Security
Socket Permissions
The IPC socket is created with restricted permissions:- Only accessible to the user running Mango
- Located in user-specific runtime directory
- Protected by filesystem permissions
Trusted Clients
IPC allows full control over the compositor:Best Practices
- Validate input in IPC scripts
- Avoid running untrusted IPC clients
- Monitor IPC usage if security is a concern
- Use IPC for automation, not as a workaround for missing features
Development and Documentation
IPC Protocol Reference
For detailed protocol documentation:- Check the Mango wiki for IPC guides
- Review
src/ext-protocol/dwl-ipc.hfor protocol details - Examine dwl-ipc compatible tools for implementation examples
- Join the Mango Discord for community support
Contributing IPC Tools
Share your IPC tools with the community:- Create GitHub repositories for reusable tools
- Document IPC command usage
- Share scripts in community channels
- Contribute to IPC client libraries
Related Features
- Custom Scripts - Automating Mango workflows
- mmsg IPC Tool - Complete IPC tool reference
- Window Commands - Window control commands
- Tags - Tag-based workspace system
