Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[How to] Use Foliate in Android phone with Termux #690

Closed
archisman-panigrahi opened this issue Mar 17, 2021 · 2 comments
Closed

[How to] Use Foliate in Android phone with Termux #690

archisman-panigrahi opened this issue Mar 17, 2021 · 2 comments
Labels
discussion Just casual conversations

Comments

@archisman-panigrahi
Copy link
Contributor

archisman-panigrahi commented Mar 17, 2021

This is not a native Android build, but uses an Ubuntu (or Arch) rootfs in Termux, and exports the GUI with VNC.

Summary:

  • Install Termux in Android
  • Set up Ubuntu rootfs (or your favorite distro)
  • Install a DE like XFCE in it
  • Set up VNC
  • Install Foliate, and configure it to run without sandbox (which Android does not allow for some reason)

Refer to the comment below for details 👇 👇 👇 👇

@archisman-panigrahi archisman-panigrahi added the discussion Just casual conversations label Mar 17, 2021
@archisman-panigrahi
Copy link
Contributor Author

archisman-panigrahi commented Mar 19, 2021

Here is how to install Foliate in an Android device without rooting

  1. Install Termux from F-Droid or Play Store (Google Play version of Termux is not anymore updated).
  2. Install Ubuntu 20.04 with proot in Termux (you can use AnLinux (free software) or proot-distro (free) or Andronix (not completely a free software) to automate the process). Andronix seems to have the most convenient user experience.
  3. Now install a desktop environment (XFCE worked for me), and set up a VNC server (Anlinux and Andronix can automate these tasks for you). To start a new XFCE session, enter the command vncserver-start.
  4. Install a VNC viewer app in Android, e.g. androidVNC (free software), or VNC viewer (non-free). VNC viewer is more convenient to use.
  5. Install Foliate (I used the stable PPA in Ubuntu). Snap packages do not work in proot, I have not checked flatpak.
  6. The Foliate .desktop file needs to be edited, to prevent sandboxing (which Android does not allow for some reason). You may find Hacker's Keyboard very helpful to edit files in a small screen. It is available in F-Droid as well as in the Play Store.
    Open the .desktop file of Foliate (nano /usr/share/applications/com.github.johnfactotum.Foliate.desktop), and edit the Exec entry to
    Exec=WEBKIT_FORCE_SANDBOX=0 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
    You may want to keep the modified .desktop file in your desktop, as you would need to copy it to /usr/share/applications every time Foliate is updated to a new version.

(I found that adding WEBKIT_FORCE_SANDBOX=0 to .bashrc does not work here).

To run Foliate after installation

Once installation is done,

  • Open Termux
  • Start Ubuntu
  • Start VNC Server
  • Open VNC viewer app in Android
  • Enjoy your favorite books in your favorite ebook reader.
  • When closing, first close Foliate, then turn off the vncserver (vncserver-stop) in Termux, and then close ubuntu (exit in Termux shell).
    If you forget to close vncserver before closing Ubuntu, you may have to manually remove the lockfile for vncserver, before you can start VNCServer once again.

Screenshots

Portrait mode (Foliate in full screen)

IMG_20210319_205447_resized

Landscape mode

1616164471826_resized

1616164471836
1616164471847

Additional tips/comments:

  • You can set a custom resolution, which suites your screen size. For me, the fonts were too small with the default (1900x1200) resolution, and I changed it to 1500x700 in my 6.5 inch phone.
  • You can also appropriately set the custom resolution to fit your device in portrait mode (eg. 700x1500), and use Foliate in single column mode (only RealVNC seems to properly support the portrait mode)
  • You can set Foliate to full screen
  • Ubuntu + XFCE + Foliate consumes ~ 1.2 GB of storage, and 300 MB of RAM. It may be less if you use a window manager like i3 instead of XFCE, but I have not tried that.
  • You can install your favorite GTK theme to make Foliate (and other apps with CSD) look native on XFCE.

What works:

Opening local books, downloading books from OPDS catalogues, library, dictionary, themes, font size, two column/ single column view, touch to turn page, text-to-speech, basically everything. Text-to-speech works (tried epeak-ng) only after enabling sound. I had to use some special tweaks to use gTTs.

What does not work:

  • Two finger swipe/pinch to zoom - This is due to limitation of the VNC viewer apps, which do not seem to support multi touch. It is not a Foliate bug.
  • Double click to open books sometimes does not work. The workaround is to open books from Foliate's "open" menu. Termux can access your phone's internal storage.

Why Ubuntu?

I chose Ubuntu due to its relatively less download size, and because it worked.
Feel free to add workarounds for your favorite distro in subsequent comments.

While Alpine is very small in size (<300 mb with XFCE and Foliate) Foliate keeps loading books forever for some reason despite editing the .desktop file.
Arch/Manjaro consume a lot more space compared to Ubuntu, but I have verified that Foliate also works in Arch.

Feel free to post suggestions/enhancements.

@archisman-panigrahi
Copy link
Contributor Author

archisman-panigrahi commented Mar 19, 2021

This is a workaround for #336
I also tried to build Foliate natively in Termux (without proot) with meson, but gjs is not available. I then tried to build gjs from source, but it depends on gobject-introspection, which is yet to be available on Termux. Once it is available, Foliate may be natively installed in Termux (where XFCE and VNC server are already available), which would make the process simpler, and consume less disk space.

Meanwhile, if you are able to somehow compile Foliate/gjs/gobject-introspection natively on Termux, do let us know, and send a pull request to Termux packages.
Update: gobject-introspection is now natively available in Termux, but gjs fails to build as mozjs-78 is not available.

@archisman-panigrahi archisman-panigrahi changed the title Using Foliate in Android phone with Termux [How to] Use Foliate in Android phone with Termux Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Just casual conversations
Projects
None yet
Development

No branches or pull requests

1 participant