ubuntu google-pin
sudo apt-get install fcitx-googlepinyin
im-config
Click through and select fcitx. Click through.
Restart your computer. Click the keyboard in the top right corner. Press Configure Current Input Method. Press + to add a new language. De-select “Only show current language”. Type in Google-Pinyin. Press OK. To switch between keyboards press Ctrl+Space