Google CloudPrint on Linux

Linux
Author

Vinh Nguyen

Published

May 12, 2011

Google CloudPrint allows users to print to the cloud from devices such as your mobile phone. That is, you can print documents and pictures from your phone to printers you have access to (e.g., at home) but is not directly connected to your phone. As of 5/12/2011, only printing from mobile Gmail and Google Docs (from the browser) are supported besides the Chrome OS. Also, only printers that are accessible to computers running Windows or Mac with the Chrome browser installed are supported. What about Linux? This thread points to the cloudprint python program. I installed it and have it started at startup via the following:

git clone https://github.com/armooo/cloudprint.git
sudo apt-get install python-pip
sudo pip install daemon
sudo python setup.py install
## or skip the whole git process and do: sudo pip install cloudprint
## place content daemon script in /etc/init.d/cloudprint
sudo chmod +x /etc/init.d/cloudprint

where the daemon script was adapted from this:

#!/bin/bash
# /etc/rc.d/cloudprint
# Description: Starts the Google Cloud Print script on startup
# ----------------
#
### BEGIN INIT INFO
# Provides: Cloud-Print
# Required-Start: $cups $network $local_fs $syslog
# Required-Stop: $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Start Google Cloud Print
### END INIT INFO

case $1 in
 start)
 echo -n "Starting Google Cloud Print: "
 ##/root/cloudprint/cloudprint.py
 sudo -u vinh cloudprint -d
 ;;
 stop)
 echo -n "Stopping Google Cloud Print: "
 ##killall cloudprint.py
 ;;
 restart)
 # echo -n "Restarting Google Cloud Print: "
 ##killall cloudprint.py
 ##/root/cloudprint/cloudprint.py
 killall cloudprint
 sudo -u vinh cloudprint -d
 ;;
# echo "Usage: cloudprint {start|stop|restart}"
esac

Then, add it to the startup list: sudo update-rc.d cloudprint defaults.

Make sure you log in manually at least once so that you can enter your username and password.

UPDATE 5/19/2011: I modified the init script so that I can print from a particular user. That way, if I print to cups-pdf, my files will be in ~/PDF/. When cloudprint is run as root, I don't know where the PDF's generated from cups-pdf are. The README and /etc/cups/cups-pdf.conf documentation states that outputs are always in $HOME/PDF, and anonymous files are stored in /var/spool/cups-pdf/ANONYMOUS. However, I do not see the files in these locations. Therefore, I will just run cloudprint as my myself instead of root.

Also, I discovered PrinterShare, a pretty useful printing app for Android devices.

UPDATE 4/2/2012: You actually need to hard code your google credentials in order for the daemon to work (path: /usr/local/lib/python2.7/dist-packages/cloudprint-0.5-py2.7.egg/cloudprint/cloudprint.py). As I did not want to expose my credentials, I created a new gmail account dedicated to CloudPrint. I hard code these credentials, and add the google account to my Android device.