How to Install Ubuntu Apps (e.g. Foliate ebook reader) on my Android device running Ubuntu Base image?

I have set up Ubuntu Base image for Arm on my Android phone and now I want to install some apps.

How do I set up the eBook reader Foliate?


This answer does not require a rooted Android device.

General Software installation

Almost all apps in the official Ubuntu repositories (e.g. LibreOffice, GIMP) are also available for ARM, and the procedure for their installation is same as in a AMD64 desktop computer. By default, you are the root user in Termux, and you won't need sudo.

apt install name-of-the-app

enter image description here Mypaint in XFCE desktop in an Android phone

For some reason, Android does not allow running sandboxed apps distributed through snap and flatpak channels (Flatpak shows segmentation fault when one tries to add the flathub repo). I have not tried appimages.

Foliate

However, certain apps (like Foliate) need some special tweaks after its installation. Since snap and flatpak are not available, we can install Foliate with its PPA.

add-apt-repository ppa:apandada1/foliate
apt update
apt install foliate

At this point you will notice that it opens, but goes into an endless loop when one tries to open a book.

The workaround is to prevent sandboxing in Webkit, which Android does not allow for some reason. You can use Hacker's Keyboard or scrcpy to conveniently edit files in a phone.

Open a terminal, and enter the command

nano /usr/share/applications/com.github.johnfactotum.Foliate.desktop

(Alternatively, you can use a GUI text editor)

And change the the Exec entry to

Exec=WEBKIT_FORCE_SANDBOX=0 com.github.johnfactotum.Foliate %U

(previously it was Exec=com.github.johnfactotum.Foliate %U)

And, for the library view (at the end of the .desktop file),

Exec=WEBKIT_FORCE_SANDBOX=0 com.github.johnfactotum.Foliate --library

enter image description here Foliate running in XFCE desktop in a phone

Now exit and restart Ubuntu. Foliate would open books successfully. I found that adding WEBKIT_FORCE_SANDBOX=0 to .bashrc does not work for some reason.

Fullscreen Foliate portrait

Foliate in fullscreen mode. The screen resolution is manually set to 700x1500 to force portrait mode.

Tips/Workarounds:

  1. Opening Books - Sometimes, Foliate opens the previously read book when you double click a new .epub file. The workaround is to use Open... in the Foliate menu, and select in the the book you want to open with the file manager.

  2. Handling updates - The edited desktop file would be replaced when Foliate receives an update. You can copy the edited .desktop file to your desktop

    cp /usr/share/applications/com.github.johnfactotum.Foliate.desktop /root/Desktop/
    

    and restore it after Foliate is updated

    cp /root/Desktop/com.github.johnfactotum.Foliate.desktop /usr/share/applications/
    
  3. Portrait Mode - If you want to read books in portrait mode, change the screen resolution of VNC server to something like 700x1500 (you can find what best fits your phone screen with some trial and error.) Foliate would automatically switch to portrait mode.

  4. Fullscreen Mode -- You can make Foliate fullscreen (Menu --> Fullscreen icon).

  5. Text to speech -- You will have to enable sound to use Text-to-speech. See this question and answer for Google Text to speech (its quality is much better than espeak or festival)

  6. Themes - The default looks of any DE installed in the Ubuntu Base image may not be very good. You can install GTK themes and Icon themes to make apps look better. Many good themes (e.g. Arc GTK theme and Papirus Icon theme) are already available in the official Ubuntu repositories.