Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use explicit raw JSON from busctl #490

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pnelson
Copy link

@pnelson pnelson commented Dec 31, 2023

Some time ago makoctl mode mysteriously stopped working for me with a jq error that seemed to indicate bad JSON content. I finally took some time to debug it and it was because I had set SYSTEMD_COLORS=16 for my user. The -j flag on busctl appears to be sensitive to this. Changing it to --json=short will ensure the output of that command is always raw.

$ SYSTEMD_COLORS=16 busctl -j --user call org.freedesktop.Notifications /fr/emersion/Mako fr.emersion.Mako -- ListModes | jq '.data[0]'
jq: parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 1, column 18
$ SYSTEMD_COLORS=16 busctl --json=short --user call org.freedesktop.Notifications /fr/emersion/Mako fr.emersion.Mako -- ListModes | jq '.data[0]'
[
  "default"
]

@fluix-dev
Copy link
Contributor

This looks good to me, and it matches the man pages:

--json=MODE
    When used with the call or get-property command, shows output
    formatted as JSON. Expects one of "short" (for the shortest
    possible output without any redundant whitespace or line
    breaks) or "pretty" (for a pretty version of the same, with
    indentation and line breaks). Note that transformation from
    D-Bus marshalling to JSON is done in a loss-less way, which
    means type information is embedded into the JSON object tree.

-j
    Equivalent to --json=pretty when invoked interactively from a
    terminal. Otherwise equivalent to --json=short, in particular
    when the output is piped to some other program.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants