RcGcDw Script setup for Android phone

Introduction

Ever since I started writing RcGcDw as a project to be shared with others – I always knew that the biggest drawback of solution I chose to use will be that it requires a server to be run on to be truthfully useful, and not many got one of those, or are technically knowledgeable to setup one properly.

After all, if RcGcDw doesn’t run 24 hours every day, what’s the point of having any notification system like that?

I’m aware of this weakness, however for many, it could be fairly easily mitigated with hardware they already own but don’t use – Android phone. Unfortunately we are kinda wasteful when it comes to electronics such as phones, and we change phones fairly often for very petty reasons, or just because we get something newer and shinier. Old phone can still be utilized for a good cause however! This is a guide on how you could achieve that for RcGcDw, made for people who are tech-literate but not on high level. Let’s begin!

Prerequisites

For fully functioning RcGcDw you’ll require:

  • A device with Android version 7.0 or higher1
  • A charger to that device

Tools 🛠️

We will require an Android application called Termux and Internet access. To obtain Termux you may want to download F-Droid, which is an alternative app catalogue for Android apps (I seriously recommend it as well! It’s wonderful to discover apps that respect your privacy and are free)

You could potentially obtain .apk file from F-Droid website itself, however it’s easier to keep it updated and make sure your download is secure with F-Droid installed.

Once you have Termux installed, we can proceed to the next section…

Magic ✨

I call this section magic, as using Termux on Android is something that I found absolutely fascinating when I first discovered it, and to this day I feel like a god. When you use apps on Android, you feel restricted in functionality to whatever they can do. With Termux? You can do anything, ok, fine, not anything but a lot of awesome things! Setting up RcGcDw is one of them.

But when you open it… You just see a black screen with some text, it likely doesn’t make you feel all powerful. It’s fine, sometimes we might have all the powers and not even realize it.

Your next step is to install even more software onto Termux this time. Don’t worry, you don’t have to look at app stores or Internet this time. From now on, we will be typing (or copying if you are fancy). Lets install a bunch of programs we will need. If it’s your first adventure with black terminals – whenever I show you a snippet like the one below, only type the part after $ character2.

$ pkg install libxml2 libxslt python openssl git

You should see something like: Package Installation in Termux Hit Return button and let it all install.

After it’s finished, you will see your favorite $ sign at the start, awaiting your input. Our next goal is to obtain RcGcDw itself, we can do this by simply cloning the repository.

$ git clone https://gitlab.com/piotrex43/RcGcDw.git

Result of running git clone

It also should take only a moment, it’ll be around 4MB of data to download.

Python magic 🐍✨

When it’s done, we are halfway there! Probably… All that’s left is to install Python dependencies for RcGcDw, configure it and… Run.

Surprisingly installing Python dependencies can take a while. One of dependencies has to compile to be working, so it takes a bit of time. We will do something before downloading requirements, that will let Termux work even when phone screen goes black. termux-wake-lock is a command that allows Termux to work even then, Android will ask you for permission for Termux to work in the background, accept it.

$ termux-wake-lock
$ pip install -r requirements.txt

Installation of RcGcDw Python dependencies

When this is happening, you could look into configuring RcGcDw. RcGcDw is configured by settings.json file. You can obtain example one from repository directly, it will be called settings.json.example. I recommend filling it up on your computer and sending it to phone later using method of your choice (personally I love KDEConnect for that kind of stuff), as doing so on phone might be a little bit annoying and complicated.

Since it’s a JSON file, it shouldn’t be difficult to work with it. However if after a while of staring at it, you still don’t understand it, I’m afraid explaining JSON format is out of scope for this guide. But I’m sure web offers some help on that!

Main keys we’ll want to focus on will be wiki_url and webhookURL. First one dictates URL to the wiki from which you want to get changes from, and second one takes Discord Webhook URL. For the wiki one, simply get the URL from your wiki, that leads not to a single page, but to its “home” (so for example, for Minecraft wiki it would be https://minecraft.fandom.com/, there is no /wiki/ there). For Discord webhook… You can see how to obtain Webhook URL on official Discord help page.

RcGcDw is powerful because of customizable it is. This is why I encourage you to edit a bit more to get the most of what RcGcDw has in offer. You can refer to settings.json documentation.

When your file is done, copy it to your phone and put it into RcGcDw directory. Make sure you remove .example from its name, it should be called just settings.json.3

Is all of that done? Python dependencies installed and settings.json in place? Oh boy, it’s time for some grand fireworks.

To start RcGcDw you have to be in RcGcDw directory (most likely ~/RcGcDw) and use python start.py. In theory this should start RcGcDw

Running RcGcDw

If that’s what you see, then congratulations. You’ve transformed your old phone you likely wouldn’t do anything with into a mini-server! If you failed along the way… I’m sorry. There are multiple points of failure even though I tried. However hit me up and I’ll do what I can to help you solve your issues.

But Frisk! There’s a problem!

Now now, yes, I know. The spell isn’t finished before we do last one magical trick. When you leave your Termux running and the screen fades, it’s very likely RcGcDw will… Stop working until you turn the screen back on. It’s Android’s smart way to save battery by forcefully putting apps to sleep. However there is a solution to this madness, and in fact, we’ve already used it once before, which is why it might work fine if you haven’t restarted Termux session in between. It’s termux-wake-lock.

You can easily make it disable this aggressive sleeping behavior by asking Termux to enable this behavior each time you open it. You will require just two commands:

$ echo "termux-wake-lock" >> ~/.profile
$ echo "termux-wake-unlock" >> ~/.bash_logout

After doing that, each time Termux session is started, it will not be put into sleep by Android anymore, which is wonderful if you want to run RcGcDw.

Other tips

  • You may want to run multiple RcGcDw scripts at once, and it’s also very much possible to do so. Personally I’ve always used screen program to do this, however there are more terminal multiplexers out there, you may want to check out tmux, as it seems to be a modern alternative. Both of those are available on Termux so they are just pkg install away. However I’ll not cover their usage in here.
  • If you want your mini-server to work all the time, I’d advise plugging the phone to a charger indefinitely. Fair warning – it will likely result in faster degradation of battery life but you wouldn’t do anything with your old phone anyway, right? (oh, also, be aware that electricity is mischievous and it may burn your house down one day)
  • I’ve tested this solution for good 12 hours and found no big issues. Since RcGcDw is not demanding the battery drain is insignificant. It survived changing networks, losing connection just fine. Just be aware that your mini-server is as reliable as power and Internet connection you have, so if your ISP decides to cut some cables there is not much we can do about it.

References


  1. Requirement comes from Termux minimal supported Android version, this may change in the future as nothing I write is eternal. ↩︎

  2. All it does is it signifies start of command prompt. ↩︎

  3. If you don’t know how to move it back there I personally would use Termux commands to get the file from Downloads directory to Termux’s own storage. This requires running termux-setup-storage command, and using cp command to copy the file from ~/storage/downloads/<your_file_from_Downloads> to ~/RcGcDw/settings.json↩︎

Creative Commons License
This post content is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License unless specified otherwise.