In this post I’ll share how I approach app development and show you how to build a screen recording app for the Librem 5. You can follow the rest of the “Easy Librem 5 App Development” series on our blog.

The Librem 5 is ideal for all types of development because it has a Free Software Foundation endorsed operating system where all the source code is released publicly, it is the same operating system—PureOS—that powers the Librem Laptops, Librem Servers, and Librem Mini. This freedom allows development and full access to things like haptic feedback, ambient light sensor, accelerometer and proximity sensors, Bluetooth, and accessing the internet. And unlike other smartphones we don’t restrict what you can do on your device, which means you can create powerful apps like an unrestricted screen recorder!

To get started pick your preferred development language and take a look at the libhandy and Librem 5 docs. Here are some examples of adaptive apps written in C, Python, Rust, and Vala.

Research:

Stand on the shoulder of giants, don’t overlook researching what has be done before, time spent in this phase can save you hours later. Be on the lookout for projects, forum or blog posts that have tackled similar problems. If you are struggling to find something, divide your app into smaller problems and piece together multiple sources to get closer to your solution.

Prototyping:

Now that you’ve divided your project up and know how to start solving each part it’s time to prototype! In this phase, you want to test each API, library or code snippet that you want to use. You are trying to solve the core logic of your app, the backend, without the user interface.

Convenience:

Once the backend problems are solved, it’s time to think about how you want to interface with the app. You can build a GTK or QT interface or use a tool like yad to automate parts of the process for you. A desktop launcher (icon) can be added in /usr/share/applications/ or ~/.local/share/applications/

Example:

Watch the full tutorial to see how I followed this process to create the Librem 5 screen recording app:

Because we share so much code with wlroots in our compositor, applications targeting wlroots have a good shot at just working. wf-recorder is a screen recording app that falls into this category, it works well after following the apt setup directions.

Here is the example GUI wrapper from the video:

#!/bin/bash
VIDEO="/home/purism/Videos/$(date +%Y-%m-%d-%H%M%S).avi"
yad --title ScreenCapture --text "A simple GUI to record the screen" --button="Start capture:100" --button="Quit:0" --buttons-layout=center
start_window_return=$?

if [[ $start_window_return -eq 100 ]]
then
    wf-recorder -a -f $VIDEO --codec=asv1 &
else
    exit
fi

yad --title ScreenCapture --text "Screen capture is actively running. \nFile: $VIDEO" --button='Stop capture:100' --buttons-layout=center
exit_window_return=$?

if [[ $exit_window_return -eq 100 ]]
then
    killall -2 wf-recorder
fi

if test -f "$VIDEO"
then
    notify-send ScreenCapture "Video stored at $VIDEO"
fi

~/.local/share/applications/screencap.desktop looks like:

[Desktop Entry]
Name=Screen Capture
Type=Application
Icon=emblem-videos-symbolic
Exec=screen_cap.sh
Categories=Utility;

Conclusion:

If you think of a cool app idea, give it a shot! Questions can be answered by us and our community over on our matrix channel or on our forum.

Discover the Librem 5

Purism believes building the Librem 5 is just one step on the road to launching a digital rights movement, where we—the-people stand up for our digital rights, where we place the control of your data and your family’s data back where it belongs: in your own hands.

Preorder now

Recent Posts

Related Content

Tags