-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings-list.py
executable file
·52 lines (42 loc) · 1.8 KB
/
settings-list.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
import gi
gi.require_version('Gio', '2.0')
from gi.repository import Gio
def main():
# Get the default schema source
schema_source = Gio.SettingsSchemaSource.get_default()
print(f"Default schema source: {schema_source}")
# List all schemas (recursively) using list_schemas(True)
schemas = schema_source.list_schemas(True)
print("Schemas:")
# Iterate through the list of lists of schemas
for schema_branches in schemas:
for schema_branch in schema_branches:
print(f"- {schema_branch}")
print("\nDetails for schemas and keys:")
# Iterate through each schema branch
for schema_branches in schemas:
for schema_branch in schema_branches:
# Retrieve and check the schema
schema = schema_source.lookup(schema_branch, True)
if not schema:
continue
if not schema.get_path():
print(f" Skipping relocatable schema: {schema_branch}")
continue
# Create a Gio.Settings object for each schema
settings = Gio.Settings.new(schema_branch)
# ^ Can cause crash if relocatable. See:
# - <https://stackoverflow.com/questions/78966924/how-do-i-check-if-a-listed-gio-schema-is-good-glib-gio-error-attempting-to-crea>
# - same as linux-preinstall/doc/issues-external/2024-09-09_gio_settings_crash.md
# Retrieve and list all keys for the schema
keys = schema.list_keys()
if not keys:
continue
for key in keys:
full_key = f"{schema_branch}.{key}"
# print(full_key)
value = settings.get_value(key)
print(f" Key: {full_key} = {value}")
if __name__ == '__main__':
main()