PeterMosmans / ansible-role-customize-gnome

Ansible role that customizes the GNOME desktop. It installs fonts and GNOME extensions from packages or zip files, copies files like desktop backgrounds and GNOME shell tweaks to a host, and modifies user settings.
GNU General Public License v3.0
74 stars 20 forks source link

gnome_dconf really hard to use #21

Closed four43 closed 1 year ago

four43 commented 2 years ago

I am having myself just a time trying to get dconf to work happily with some complex values. Gnome Clocks is the tricky one, they store their values as some sort of pickle like value? It has spaces in it, which don't get quoted when passed to the shell command call:

  # [org/gnome/clocks]
  - key: "org/gnome/clocks/world-clocks"
    value: "[{'location': <(uint32 2, <('Boulder', 'KBJC', true, [(0.69654151386294727, -1.8346416244498187)], [(0.69847106261748959, -1.8377056546714499)])>)>}, {'location': <(uint32 2, <('Helsinki', 'EFHF', true, [(1.0515608743265836, 0.43720497762457955)], [(1.0502615814182288, 0.43518331039211688)])>)>}]"

Results in an error:

failed: [localhost] (item=org/gnome/clocks/world-clocks) => {"ansible_loop_var": "item", "changed": false, "cmd": ["dbus-launch", "dconf", "write", "org/gnome/clocks/world-clocks", "[{location:", "<(uint32", "2,", "<(Boulder,", "KBJC,", "true,", "[(0.69654151386294727,", "-1.8346416244498187)],", "[(0.69847106261748959,", "-1.8377056546714499)])>)>},", "{location:", "<(uint32", "2,", "<(Helsinki,", "EFHF,", "true,", "[(1.0515608743265836,", "0.43720497762457955)],", "[(1.0502615814182288,", "0.43518331039211688)])>)>}]"], "delta": "0:00:00.016813", "end": "2022-09-23 17:26:22.180773", "item": {"key": "org/gnome/clocks/world-clocks", "value": "[{'location': <(uint32 2, <('Boulder', 'KBJC', true, [(0.69654151386294727, -1.8346416244498187)], [(0.69847106261748959, -1.8377056546714499)])>)>}, {'location': <(uint32 2, <('Helsinki', 'EFHF', true, [(1.0515608743265836, 0.43720497762457955)], [(1.0502615814182288, 0.43518331039211688)])>)>}]"}, "msg": "non-zero return code", "rc": 2, "start": "2022-09-23 17:26:22.163960", "stderr": "No protocol specified\nerror: dconf key must begin with a slash\n\nUsage:\n  dconf write KEY VALUE \n\nWrite a new value to a key\n\nArguments:\n  KEY         A key path (starting, but not ending with '/')\n  VALUE       The value to write (in GVariant format)", "stderr_lines": ["No protocol specified", "error: dconf key must begin with a slash", "", "Usage:", "  dconf write KEY VALUE ", "", "Write a new value to a key", "", "Arguments:", "  KEY         A key path (starting, but not ending with '/')", "  VALUE       The value to write (in GVariant format)"], "stdout": "", "stdout_lines": []}

See the cmd part that has all the args split on spaces. What compounds the issue is that the dconf write command is really picky anyway, requiring some escaped quotes even if there aren't spaces.

dbus-launch dconf write /org/gnome/clocks/world-clocks "[{'location': <(uint32 2, <('Boulder', 'KBJC', true, [(0.69654151386294727, -1.8346416244498187)], [(0.69847106261748959, -1.8377056546714499)])>)>}, {'location': <(uint32 2, <('Helsinki', 'EFHF', true, [(1.0515608743265836, 0.43720497762457955)], [(1.0502615814182288, 0.43518331039211688)])>)>}]"

Seems to work however. Though strings really need to be strings

dbus-launch dconf write /org/gnome/desktop/background/picture-options "\"zoom\""

Any thoughts/tips? This is tough to convey in YAML

four43 commented 2 years ago

Maybe this is just another :+1: for https://github.com/PeterMosmans/ansible-role-customize-gnome/issues/13

PeterMosmans commented 2 years ago

Hi @four43 - thanks for the feedback. Yeah, I agree with both statements: The current situation is difficult with regards to complex strings and YAML, and the community dconf module is the way forward. I'll be looking into that...

four43 commented 1 year ago

Much appreciated. Thanks for the great module here. I'm having a lot of fun with it!

PeterMosmans commented 1 year ago

Hi @four43 , please see version 0.2.8 where I've implemented the native dconf module. Let me know if this works for you...