There it is.
A simple first Vala programming language project running on Termux.
Hello Hivers
Instead of creating a tiny Hello World program displaying a message in a terminal, I wanted to create a simple window version of that. Later it will become more useful, I think. It is part of a project where I use Termux running on an old Xiaomi Redmi 5 plus and a X96 Mate plus mediaplayer. It is Linux in an Android enviroment, the Xiaomi is running Oreo and the X96 the TV 10 version. By default it has only a terminal available. And though it is possible to install a Linux distribution like Ubuntu (and then some) I decided to use the basic Termux (Android App) setup. Using F-Droid to install Termux. While XFCE4 is the lightweight Desktop that I am using. Working remotely using a the TigerVNC system. It did not come right out off the box, but it took some (more than I want to admit) trials, errors and curses...
Compiling a C language application is pretty straightforward. Normally, on a full blown Linux distribution, it just needs a little patience. Termux is an Android App and needs some (smart) trickery to be able to compile anything on it. It is running on an ARM (AARCH64) based CPU, but that does not have to be an issue. The include and lib path settings were giving me most trouble and some include file not being where it should. For some header files I made a little change in the include part. And then pkg-config also did what it had to do. Trying to compile a simple browser written in C got an error on the webkit part. Again something with a different path and a another version of a library that needs to be linked. Left that for another trial and error session.
Vala does what it needs to do.
Vala is a transcompiler language. It takes the Vala source code translates it to C and then compiles the C code into a working application. As I am not a programmer by definition but more like a geek, I do dislike C a lot. The Vala language is more to my liking. And on my Lubuntu driven Laptop it works right out off the box. On the Termux App running on Android it was somewhat different. Somehow the include and lib files were found the way they should. Had Pidgin installed, but it was unable to do anything. Time to try if the clang compiler issues were solved. Getting the source code for building a Telegram plugin and have it do its thing. And hey presto! Now Pidgin has one working plugin.
Next up a little Vala code to create a (GTK based) Window. The code is pretty self explaining (For coding I use Geany, it is easy to install on Termux):
// Namespace used
using Gtk;
// Webkit still triggers unsolved errors in Termux
// !using WebKit;
// Basic window setup
int main (string[] args) {
// First init Gtk
Gtk.init (ref args);
// Create a window object
var window = new Window ();
// Add some Window settings
window.title = "Hello Hivers!"; // A title
window.set_default_size (620, 380); // Width and Height
window.border_width = 8; // Border
window.window_position = WindowPosition.CENTER; // Center it
// Make it destroy able
window.destroy.connect (Gtk.main_quit);
// Show it
window.show_all ();
// Run main Gtk
Gtk.main ();
// Return 0 int value on exit
return 0;
}
Some bashing needed too.
While I work remotely on the Xiaomi (through VNC), using my laptop, the experience is as if I am working on a Linux driven computer. That did surprise me at first, as I was expecting it to be a constant lag experience. On the XFCE4 desktop I have a terminal ready at my fingertips. So I can bash at it right away. For my projects on the ARMed hardware I set up a folder structure like: ~/prj and then for every language a subfolder like c , cpp, py and vl. That last one is for the Vala stuff. In there goes the main project folder: haifa. Which gets folders inside like: src (source) and rls (release). And even dbg (debug) might be added someday. It is a setup that I find easy to use. (In Termux ~ also can be reached by using $HOME.) And when the directory structure is there, all that needs to be done is bashing it with some commands.
cd ~/prj/vl/haifs
valac --pkg gtk+-3.0 src/haifa.vala -o rls/haifa
./rls/haifa
And if all is going well there should appear a Window in the middle of the Desktop with the title 'Hello Haifers'. If the application should be run from anywhere it it has to be copied | moved to the bin folder. And from there it can be started just by using the name haifa. Not that much exciting happens, just a simple Window appearing on the Desktop. But to me it was another small victory. The WebKit error is still bugging me, but that is for another time. So far it is fun to see how Termux can be used to give unused Android hardware another purpose in the local network. Running 24/7 while hardly using 10 Watts per hour the Xiaomi Redmi 5+ certainly can have its use for some blockchain related stuff. With Beem, Hive-Engine and Distribubot functioning in Python as they should really makes the Geek in me happy.
Time to get outside.
Enough screen staring for today, as it is a beautifull spring day here in Oldambt, it is time to get me some of that sunny vitamine D. Next time I will see how I can run a Vala GUI to use on top of Python. Or maybe I'll have a go at Golang? The Xiaomi has been running constantly for days now, without Termux crashing. Where the Mediabox did crash several times. Anyway now it is time to get away from the keyboard. Oaldamster out!
Have a great one!
YES! Finally some real progress in Termux.
Screenshot by Oaldamster