Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
13
rated 0 times [  13] [ 0]  / answers: 1 / hits: 6226  / 3 Years ago, sat, september 11, 2021, 2:57:50

I would like to know the default value of a dconf/gsettings key.



My question is a followup of the question below:
Where can I get a list of SCHEMA / PATH / KEY to use with gsettings?



What I'm trying to do, so create a script that reads all my personal preferences so I can back them up and restore them. I plan to iterate though all keys, like the script above, see what keys have been changed from their default value, and make a note of these, that can be restored later.



I see that the dconf-editor display the keys' default value, but I'd very much like to script this. Also, I don't see how parsing the schemas /usr/share/glib-2.0/schemas/ can be automated. Maybe someone can help?



gsettings get-default|list-defaults would be nice =)



(Geesh, it was much easier in the old days where you just kept your ~/.somethingrc in subversion ... =






Based on the answer given below, I've updated the script to print schema, key, key's data type, default value, and actual value:



#!/bin/bash

for schema in $(gsettings list-schemas | sort); do
for key in $(gsettings list-keys $schema | sort); do
type="$(gsettings range $schema $key | tr "
" " ")"
default="$(XDG_CONFIG_HOME=/tmp/ gsettings get $schema $key | tr "
" " ")"
value="$(gsettings get $schema $key | tr "
" " ")"
echo "$schema :: $key :: $type :: $default :: $value"
done
done


This workaround basically covers what I need. I'll continue working on the backup scrip from here.


More From » default

 Answers
2

There does not seem to be a nice way to get at the default values directly, but since the client checks XDG_CONFIG_HOME in the environment a decent workaround to get values from a fresh config might be:



XDG_CONFIG_HOME=/nonexistent gsettings get SCHEMA KEY

[#35126] Saturday, September 11, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
doredtness

Total Points: 153
Total Questions: 113
Total Answers: 106

Location: South Georgia
Member since Fri, Nov 13, 2020
4 Years ago
;