Last Updated 2024-01-18
The defaults of the Librem 5, in my experience, result in slow internet searches. Too often, I have whipped out my Librem 5 to retrieve some information from the internet for my friends, and someone else retrieves the information first, because they tire of waiting for me and my GNU/Linux phone.
Unfortunately, the default method of searching the internet involves several steps, none of them particularly snappy: press the power button to turn on the screen; swipe up on the lock screen to reveal the PIN entry; type in PIN; tap firefox icon (firefox takes about ~10 to 20 seconds to load); type in and enter query.
I set out to streamline this process, and, after a fair amount of experimentation, I landed on the following solution. If you want to borrow some or all of these strategies, great! Some steps are more time-consuming than others, so if you want to follow along from start to finish, I recommend mustering up your patience. Enjoy!
The first part of default slow internet searches–swiping up and entering my PIN–can be eliminated entirely. To do so, I added the following to /home/purism/.local/bin/unlock.sh:
while true; do loginctl unlock-session sleep 3 done
And the following to the end of my /home/purism/.profile:
/home/purism/.local/bin/unlock.sh &
Some of the software that I used seems to work better with newer versions than those available in the PureOS package manager, so I installed Guix, which packages a lot of newer software. If you’re not familiar with Guix, it is awesome. Once installed, it allows package management without sudo, and it emphasizes free software by requiring packages to publish source code. Guix is a full GNU/Linux distro in its own right, and it is my favorite for a bunch of reasons that I don’t want to distract you with right now. But, in addition to being a full operating system, it can also be installed as a package manager on top of a different distro, for example, PureOS. Installing Guix on top of PureOS is what I did.
I would add two caveats with Guix. First, ARM support is not great! More than a few packages will fail to install with errors. Using Guix on the Librem 5 is not for the faint of heart. If things going wrong easily discourages you, please skip this section! Nevertheless, the packages I mention in this article should work fine.
Second caveat, it takes significantly more time/resources to do things with Guix than it does with other package managers. For example, don’t be surprised if it takes an hour to install a package on the Librem 5 using Guix.
That said, Guix is very straightforward to install, as described on the Guix website. You can enter the following commands in a terminal to install Guix on the Librem 5:
wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh chmod +x guix-install.sh sudo ./guix-install.sh
After installing Guix, you can enter guix pull
to update Guix. This will take a few minutes.
Text-based browsers often have better startup times than more heavyweight browsers, like Firefox. So, to improve the quickness of internet searches, I installed one. w3m is a good option, but my favorite is eww (Emacs Web Wowser), which is built in to Emacs. eww has great navigation abilities, and great interoperation with Emacs text editor. I tried this solution with emacs 27, packaged in PureOS, but eww didn’t seem to work very well. So, I installed emacs 29 with Guix:
guix install emacs
To attain faster startup times for searching than the builtin terminal (kgx) can provide, I installed a faster terminal:
guix install foot
Among the slowdowns I encountered when using text-based browsers, an internet search page, such as Duckduckgo or Brave Search, takes some time to load. To remedy this, I created a local HTML page containing a form that submits a search query to Brave Search. Loading a local HTML file is much faster than loading an internet search page. I chose Brave Search because it works better than alternative search pages in text-based browsers. https://duckduckgo.com/lite
works fine, but I noticed that sometimes all the resultant links are replaced with referrer (tracking) links to Duckduckgo itself. So, I used Brave Search. I added the following to /home/purism/Documents/simple_search.html:
<html> <body> <p>Brave Search</p> <form action="https://search.brave.com/search" method="GET"> <input name="q" type="text" > <input type="submit"></input> </form> </body> </html>
Two of the softwares that I used in this solution implement a client-server option. This allows starting up an app server as a back-end, so that starting the app as a client opens the app window faster and uses less resources than starting the app as a standalone process. Starting these app servers on boot allows quickly starting the corresponding client windows on demand.
To further decrease latency, I loaded the local HTML page created above into the emacs server. To start these servers on boot, I added the following lines to /home/purism/.profile:
emacs --daemon --execute "(eww-browse-url \"file:///home/purism/Documents/simple_search.html\")" foot -s &
I wanted to have a button in my Phosh favorites tray to quickly search the internet. With the above pieces in place, here’s how I did that.
One of the secrets to a good button is a great icon ;). Well, here’s how I got mine from WikiMedia and saved it to my icons directory:
wget https://upload.wikimedia.org/wikipedia/commons/0/06/Antu_dialog-icon-preview.svg sudo mv Antu_dialog-icon-preview.svg /usr/share/pixmaps/antu_magnify.svg
As a shell script to start searching, I added the following to /home/purism/.local/bin/search.sh:
#!/bin/sh footclient -e emacsclient -nw -e "(progn (eww-browse-url \"file:///home/purism/Documents/simple_search.html\") (shr-next-link))" &
And make it executable:
chmod +x /home/purism/.local/bin/search.sh
To create my app button on my home screen, I added the following to /usr/share/applications/search.desktop:
[Desktop Entry] Type=Application Exec=/bin/sh -c "cd /home/purism/.local/bin && ./search.sh" Icon=antu_magnify Terminal=false Categories=Internet Name=Search X-Purism-FormFactor=Workstation;Mobile;
Now, an app with a magnifying-glass icon should appear on your home screen. To pin it to the top of your list of apps, long-press it and select Add to Favorites.
Finally, reboot to start your new background daemons. Tap on the magnifying-glass icon, and a search page should appear!
If you don’t know how to use Emacs or eww, that’s okay, there is a lot of documentation online. To get started, here are a few key combinations that I find useful:
l: go back one page r: go forward one page Ctrl and v: move down the page Alt and v: move up the page Ctrl and s: forward search Ctrl and r: backward search Enter: stop searching at current result Ctrl and g: quit operation G (uppercase): go to new url
After all this, I am able to pick up my Librem 5 with blanked screen and, within two seconds, begin happily typing my internet query. Hope you find this post helpful!