#!/bin/sh
# Setup for Gnome on Ubuntu

if [ ! -x /usr/bin/gsettings ]; then
    echo "You don't have gnome installed, so gnome-setup is not useful"
    exit 0
fi

S () {
    [ -z "`gsettings set $1 $2 "$3" 2>&1`" ] || echo failed to set $1 $2
}

### To find a schema:
# gsettings list-schemas | sort
# gsettings list-recursively <schema>
# for s in `gsettings list-schemas | sort`; do gsettings list-recursively $s; done

### Fix focus:
S org.gnome.desktop.wm.preferences raise-on-click true
S org.gnome.desktop.wm.preferences auto-raise true
S org.gnome.desktop.wm.preferences focus-mode 'sloppy'
S org.gnome.desktop.wm.preferences auto-raise-delay 500

### Fix key bindings:
S org.gnome.desktop.wm.keybindings activate-window-menu "['<Control><Alt>space']"
S org.gnome.desktop.wm.keybindings cycle-panels "['<Control><Alt>Escape']"
S org.gnome.desktop.wm.keybindings switch-panels "['<Control><Alt>Tab']"
# this is particularly nasty because it's not in the same place as the others
S org.freedesktop.ibus.general.hotkey triggers []

### Fix fonts:
S org.gnome.desktop.interface document-font-name 'Cantarel 11'
S org.gnome.desktop.interface font-name 'Cantarell 11'
S org.gnome.desktop.interface monospace-font-name 'Inconsolata 12'

### Fix window behavior
S org.gnome.shell.overrides edge-tiling false

### Ubuntu-specific fixes:
if gsettings list-schemas | grep -q canonical; then

    ## fix the clock applet, which is badly broken in post-unity Ubuntu
    #  Only show the time to save space, because the panel is vertical these days.
    S com.canonical.indicator.datetime time-format 'custom'
    S com.canonical.indicator.datetime custom-time-format '%H:%M'

fi
