To enable:
gsettings set org.gnome.desktop.input-sources xkb-options "['caps:ctrl_modifier']"
To disable:
gsettings set org.gnome.desktop.input-sources xkb-options "[]"
See also https://askubuntu.com/questions/971067/how-can-i-script-the-settings-made-by-gnome-tweak-tool
EDIT: To address Don's comment below you can run gsettings get org.gnome.desktop.input-sources xkb-options
to see if any other xkb-options
are already set. If there are you can incorporate them too in the gsetting command, for example you might have gsettings set org.gnome.desktop.input-sources xkb-options "['altwin:menu', 'caps:ctrl_modifier']"
xkb
options already present... see my post here... so scripting this via shell is not that simple. An easier way imo is viapython
'sGio.Settings
– don_crissti Nov 28 '22 at 21:50