This script works:
$ cat $HOME/bin/sticky_keys
xkbset exp -bell -sticky -twokey -latchlock -accessx -feedback -stickybeep -led 9999
xkbset bell sticky -twokey -latchlock feedback led stickybeep
(If you would prefer pressing Shift twice to mean "hold down shift" then change '-latchlock' above to 'latchlock')
For more and related information, you probably will like this wiki page:
Because of the missing tool 'xorgcfg' or 'xf86cfg' https://launchpad.net/distros/ubuntu/+ticket/506 in the ubuntu repository, you have to use the commandline tool 'xkbset'. Which isn't very user-friendly. You have to call 'xkbset' twice. By the first call, you set the expiry of the accessx settings. This is necessary, because there is a default timeout. By the second call, you can adjust the accessx settings themself. I don't know why, but in my settings, this was the required order!
With xkbset -h you will get a help message.
An example for setting the expiry of the accessx settings:
xkbset exp -bell -sticky -twokey -latchlock -accessx -feedback -stickybeep -led
You have to disable the expiry of all accessx settings you need. Because, if you set an explicit timeout with '0', you will cause a xorg runtime error.
An example for adjust the accessx settings: xkbset bell sticky -twokey latchlock feedback led stickybeep
For further information refer to: http://www.xfree86.org/current/xset.1.html
In the Configuration example below you see a setup for daily usage.