Florian (who's also behind the unofficial GNOME Shell System Monitor extension) has created a new extension called Focus Effects that allows you to add custom effects on window focus / blur.
According to Florian, the extension has been created to show what can be done using Clutter and to give ideas for developing fun GNOME Shell extensions similar to the Compiz plugins.
By default, the extension adds a Clutter desaturation and and opacity effect, but you can customize this by creating a file called ".ffxrc.json" in your home directory (the extension comes with an example) and then reloading GNOME Shell.
To install GNOME Shell Focus Effects Extension, make sure GIT is installed (in Ubuntu, install git-core), then run the following commands:
cd git clone https://github.com/paradoxxxzero/gnome-shell-focus-effects-extension.git mkdir -p ~/.local/share/gnome-shell/extensions cp -r firstname.lastname@example.org ~/.local/share/gnome-shell/extensions/
Update: for Arch Linux, you can find the extension in AUR (thanks to Alucryd!).
To also copy the example config file to your home folder, run the following command:
cp gnome-shell-focus-effects-extension/example.ffxrc.json ~/.ffxrc.json
Now you can tweak the effects by opening the .ffxrc.json file in your home folder (it's a hidden file so press CTRL+H to see hidden files and folders).
Once installed, restart GNOME Shell and apply the extension using GNOME Tweak Tool.
Note: you'll also have to restart GNOME Shell (or log out and log back in) after disabling the extension!
Thanks to Florian for the tip!