mako
mako copied to clipboard
Add JSON output support to makoctl list and makoctl history
This pull request adds support for JSON-formatted output via the -j flag for the following commands:
- makoctl list
- makoctl history
When the flag is provided, the output is serialized as JSON, making it easier to consume in scripts and external tools.
Changes:
- Added -j flag parsing to relevant CLI commands
- Implemented recursive serialization of D-Bus sd_bus_message structures into valid JSON
- Supports:
- Basic types: string, bool, byte, int32, uint32
- Variants (v)
- Dictionaries (a{sv}, a{ss})
- Arrays (a[...])
- Safely escapes strings and handles nested containers
Example usage:
makoctl list -j | jq .
makoctl history -j | jq '.[].summary'
Tested:
- Output is valid JSON (verified with jq)
- Handles all expected fields: summary, app-name, urgency, actions, etc
- Works with nested and complex D-Bus structures
Motivation:
This makes makoctl significantly more script- and automation-friendly, especially for use in status bars, dashboards, or notification diagnostics.
Closes #580 CC: @arebaka
really nice, hope json output could be restored soon on mako
looking forward for this to be merged!