mako icon indicating copy to clipboard operation
mako copied to clipboard

Add JSON output support to makoctl list and makoctl history

Open arebaka opened this issue 7 months ago • 2 comments

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

arebaka avatar May 30 '25 23:05 arebaka

really nice, hope json output could be restored soon on mako

parisni avatar Jul 30 '25 11:07 parisni

looking forward for this to be merged!

onion108 avatar Nov 10 '25 11:11 onion108