Created
October 9, 2023 12:13
-
-
Save dariocc/1b99514a284f2e6635b053ad0bd51b19 to your computer and use it in GitHub Desktop.
Export dconf to JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 "/") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
Output is in the format: