3

I know how to change privacy settings via GUI (System Settings > Security & Privacy), but I'd like to be able to do it from command line.

What I did to find out

I ran the command:

dconf watch /

to see what changes were made. About the command (from man dconf):

watch
    Watch a key or directory for changes.

Subsequently, I changed settings via GUI to see what happened in the output of the command. It showed:

/org/gnome/desktop/privacy/remember-recent-files false
/com/canonical/unity/lenses/remote-content-search 'none'
/org/gnome/desktop/screensaver/ubuntu-lock-on-suspend false
/org/gnome/desktop/screensaver/lock-enabled false

My question is: how can I use this information to change the settings from command line?

  • So your goal is to alter those dconf schemas you got in the output of dconf watch / ? – Sergiy Kolodyazhnyy Apr 8 '16 at 0:22
  • my goal is to learn how to change the GUI settings in command line. – blowfishgpg Apr 8 '16 at 0:48
  • that's a broad topic . There's a lot of things that change the settings, not just one tool . Since that's such a broad topic, you probably won't receive an answer on that. However those specific settings that you've listed can be changed with dconf write KEY VALUE . see askubuntu.com/q/22313/295286 and askubuntu.com/q/487206/295286 for some info . – Sergiy Kolodyazhnyy Apr 8 '16 at 0:59
  • Hi blowfishhgpg, could you mention if the answer is what you are looking for, and if you manage? – Jacob Vlijm Apr 8 '16 at 22:02
  • Great! But I can't manage to disable the diagnostics sent to Canonical. Are these keys not in dconf? At least watch doen't show anything – Janning Mar 23 '17 at 17:28
7

Different ways to edit those settings

The settings you mention are stored in the dconf database in ~/.config/dconf (in binary format). This database can either be directly edited with dconf, or via gsettings. The difference is explained at the last section of this answer.

Once you have the information, posted in your question, you can therefore change the corresponding settings in two different ways.
Using your first example (setting remember-recent-files):

using dconf write:

dconf write /org/gnome/desktop/privacy/remember-recent-files false

or

using gsettings set:

gsettings set org.gnome.desktop.privacy remember-recent-files false

Similarly, reading the current setting:

using dconf read:

dconf read /org/gnome/desktop/privacy/remember-recent-files

or

using gsettings get:

gsettings get org.gnome.desktop.privacy remember-recent-files

In the first case, you edit the dconf database directly, in the latter you are using gsettings, which is a CLI frontend to dconf.

Which way to prefer; dconf or gsettings?

To protect the integrity of your dconf database, in general, it is considered better practice to use gsettings.

Frome this link, we read:

The dconf program can perform various operations on a dconf database, such as reading or writing individual values or entire directories. This tool operates on dconf directly, without using gsettings schema information. Therefore, it cannot perform type and consistency checks on values. The gsettings(1) utility is an alternative if such checks are needed. You can see gsettings as the cli-frontside to dconf.

Read more on gsettings and dconf.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.