Monday, October 15, 2018

Printing documents from Ubuntu Touch

Early previews of Ubuntu Touch 16.04 OTA-4 came with a settings panel for configuring printers. But the dual concerns of a root image that was growing too large, and the unfinished feature being deemed expendable conspired to make it so that the feature was dropped in subsequent previews. It has not made a reappearance in the recently released OTA-5 either. I expect it will be revisited when space is made available in the root image by removing some deprecated libraries.

Need To Print

But what if I want to be able to print the attachment of an email from the convenience of my mobile device? Going up the stairs, turning on the desktop, waiting for it to boot, logging in, opening my email, then printing the attachment, takes up so much time! Accessing the correct email is so much faster on my phone. So I would want to be able to print from it too.

I got to thinking that it should be possible to set up printing in a Libertine container. And turns out it is! Let's walk through the steps. I will assume that you already have a running Libertine container. Lets call ours xenial. I will also assume that you have a network printer that is accessible in a browser under http://<address of printer server>:631. In other words, that you have a CUPS server running somewhere on your local network. For the purposes of this walk-through let us assume the IP address of the server is 192.168.0.4

The Setup

Fire up the Terminal app in Ubuntu Touch and install the CUPS client package in the xenial container:
$ libertine-container-manager install-package -i xenial -p cups-client
We only want the client package since we will not be running a CUPS server locally in the container. This would not have been possible even if we wanted to, because daemons cannot be started inside Libertine containers.
The next enter the container shell:
$ libertine-container-manager exec -i xenial -c /bin/bash
You will now be in a root shell inside the xenial container. What we need to do here is tell the CUPS client where to look for a CUPS server. The default location is localhost. But we wouldn't be running a CUPS server on the device itself. So we need to point it to our server. Remember that ours is running at address 192.168.0.4:
# mkdir -p /etc/cups
# touch /etc/cups/client.conf
# echo "ServerName 192.168.0.4" >> /etc/cups/client.conf
Now you should be able to print from any other application installed in the container. Just install your favorite editor and viewers alongside. In my setup I have installed firefox, libreoffice and evince.

Notice that if you have more than one container on your device and you want to be able to print from within that container also, you would have to repeat the above steps for that container also. So it might be worth it to take a moment to consider how you want to distribute your applications among the different containers.

No comments:

Post a Comment