Skip to content

Instantly share code, notes, and snippets.

@dariocc
Created October 9, 2023 12:13
Show Gist options
  • Save dariocc/1b99514a284f2e6635b053ad0bd51b19 to your computer and use it in GitHub Desktop.
Save dariocc/1b99514a284f2e6635b053ad0bd51b19 to your computer and use it in GitHub Desktop.
Export dconf to JSON
#!/bin/bash
awk '
/^\[/ {
gsub(/[\[\]]/,"")
f=$0
next
}
NF{
if(a[f]) s=","; else s=""
gsub(/\\/,"\\\\",$0)
gsub(/"/,"\\\"",$0)
sub(/=/,"\":\"",$0)
a[f]=a[f] s "\"" $0 "\""
}
END{
for(x in a) {
print "{ \"" x "\":" "{" a[x] "}" "}"
}
}
' <(dconf dump "/")
@dariocc
Copy link
Author

dariocc commented Oct 9, 2023

Usage:

chmod u+x dconf-to-json
./dconf-to-json | jq ...

Output is in the format:

[
  "<section>" : {
    "<key>": "<value>",
    ...
  }
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment