Ubuntu Linux Tips and Tricks

Some tips for Ubuntu Desktop LTS users

A shell script to list key-type-value with the GSettings configuration tool

Leave a comment

Copy & paste the following code into your favorite text editor, and call this shell script, for example, ‘list-schema-key-type-val.sh’:

#!/bin/sh
schema=$1
echo "*** schema = $schema ***"
echo "Key :: Type :: Value"
echo "--------------------"
for key in $(gsettings list-keys $schema | sort)
do
  type="$(gsettings range $schema $key | tr "\n" " ")"
  value="$(gsettings get $schema $key | tr "\n" " ")"
  echo "$key :: $type :: $value"
done

If you call this script with a known schema as first argument, it will go through all the entries of the schema and print their possible types/enums, and their current value. This is a little bit easier to use than the “gsettings list-recursively” since it will also tell you the type of the data.

% list-schema-key-type-val.sh org.gnome.desktop.background

This is the script output:

*** schema = org.gnome.desktop.background ***
Key :: Type :: Value
--------------------
color-shading-type :: enum 'solid' 'vertical' 'horizontal' :: 'solid'
draw-background :: type b :: true
picture-opacity :: range i 0 100 :: 100
picture-options :: enum 'none' 'wallpaper' 'centered' 'scaled' 'stretched' 'zoom' 'spanned' :: 'zoom'
picture-uri :: type s :: 'file:///usr/share/backgrounds/Beach_by_Renato_Giordanelli.jpg'
primary-color :: type s :: '#000000'
secondary-color :: type s :: '#000000'
show-desktop-icons :: type b :: true

To change the session background to the same as the one used for the previous tip on how to change the background of the unity greeter:

% gsettings set org.gnome.desktop.background picture-uri 'file:///usr/share/backgrounds/mybackground.jpg'

Leave a comment