Configure gnome-shell extensions from command line
I like to run a couple of scripts to automatically install packages and do some configurations on fresh OS installs. I use gnome shell with a few extensions and was thinking of improving my scripts to configure them.
I usually configure the extensions using gnome-shell-extension-prefs or dconf-editor and I know how to edit other schemas from the command line. Example:
gsettings set org.gnome.desktop.background picture-options stretched
But, although I can find and edit the installed extensions under org.gnome.shell.extensions using dconf-editor I can't access them using gsettings since they don't seem to have an assigned schema:
No such schema 'org.gnome.shell.extensions.extname'
The only extensions accessible with gsettings seem to be the ones that came pre-installed.
So, the question is, how can I configure the installed extensions from the command line? Is there any way to assign to gsettings the compiled schemas in ~/.local/share/gnome-shell/extensions/
? Maybe I'm looking in the wrong direction.
Environment: Ubuntu Gnome 14.04 (Gnome Shell 3.10.4)
Thanks in advance.
Solution 1:
Found the answer by myself in the end.
sudo cp ~/.local/share/gnome-shell/extensions/extname/schemas/org.gnome.shell.extensions.extname.gschema.xml \
/usr/share/glib-2.0/schemas/ &&
sudo glib-compile-schemas /usr/share/glib-2.0/schemas/
Copy and compile the schemas in ~/.local/share/gnome-shell/extensions
and gsettings will be able to work with them.
Solution 2:
In CentOS 7 - and I would think in Ubuntu also - I've identified what I think is a slight improvement on the accepted answer by introducing the --schemadir switch as follows:
# gsettings --schemadir ${schemaDir} set ${schema} ${key} "${value}"
In the above command gsettings directly sets ${key}
to ${value}
in ${schema}
where ${schema}
does not reside in the default /usr/share/glib-2.0/schemas
directory. (and there is no requirement to move the schema to the default directory)
Some examples:
gsettings --schemadir ~/.local/share/gnome-shell/extensions/[email protected]/schemas/ list-recursively org.gnome.shell.extensions.org-lab21-putwindow
gsettings --schemadir ~/.local/share/gnome-shell/extensions/[email protected]/schemas/ list-recursively org.gnome.shell.extensions.app-keys
gsettings --schemadir ~/.local/share/gnome-shell/extensions/[email protected]/schemas/ list-recursively org.gnome.shell.extensions.emoji-selector
Solution 3:
I've written this script: Bash script to enable/disable gnome-shell-extensions and more.
Just cp it in /usr/bin
or /usr/local/bin
and make it executable:
sudo chmod +x /usr/bin/gnome-shell-extension-cl
Check the help.
Enable extension:
gnome-shell-extension-cl -e extension-name
Disable extension:
gnome-shell-extension-cl -d extension-name