Distro-Agnostic Responsive Signal-Desktop

There is this app on Ubuntu Touch's OpenStore called Sigul UT, which is basically Signal-Desktop with some patches to make it actually usable on a small touchscreen. In this post I will show you how you can patch it into a non-Ubuntu-Touch version of Signal-Desktop without having to compile the whole damn thing. I'll be targeting Nura (aka postmarketOS), though it should work on any distro.

Requirements

Steps

Start from a new directory so you don't clutter up your ~. Download the files from Sigul UT:

wget https://github.com/pparent76/SigulUT/raw/refs/heads/main/patches/Signal-Desktop/inject_js_responsive.patch https://github.com/pparent76/SigulUT/raw/refs/heads/main/patches/Signal-Desktop/responsive.js

Download the appropriate Signal-Desktop source:

VERSION=X.Y.Z # Replace with the installed version of Signal-Desktop
wget "https://github.com/signalapp/Signal-Desktop/archive/refs/tags/v${VERSION}.tar.gz"
tar xf "v${VERSION}.tar.gz"

I'll now be grabbing and applying the patches from Alpine's aports (skip if using an unpatched version):

git clone --depth=1 https://git.alpinelinux.org/aports
ln -s aports/testing/signal-desktop signal-aports
cd "Signal-Desktop-${VERSION}"
for p in ../signal-aports/signal-*.patch; do
    patch -p2 < "$p"
done

If all patches fail to apply, play with the -p option (try -p1 for example). I always get one failed patch (can't find file to patch), but it's safe to ignore.

If you skipped the last step, be sure to cd "Signal-Desktop-${VERSION}". Now let's apply the Sigul UT patch:

patch -p1 < ../inject_js_responsive.patch

Before we can compile the patched TypeScript, we need to install some npm dependencies. Most of them we don't need, but I can't find a reliable way to skip the useless ones so let's just install all of them:

pnpm install --ignore-scripts

Now to compile (should be quick, we're not compiling the whole beast):

pnpm run generate:phase-0

That's all the compiling taken care of. After that we need to replace the files in our Signal installation with the new ones. For that we need to unpack the electron archive thingy, do the switcheroo and pack it back up:

pnpx @electron/asar extract /usr/lib/signal-desktop/app.asar unpacked
cp bundles/main.js unpacked/bundles/
cp -n bundles/chunks/* unpacked/bundles/chunks/
mkdir unpacked/js
cp ../responsive.js unpacked/js/
pnpx @electron/asar pack unpacked app.asar

Now just replace your original /usr/lib/signal-desktop/app.asar (or wherever yours is) with the new one in your working directory and you're done.

Congratulations, you've made this bloated mess a little less terrible! Now you just have to come back here every time you update Signal-Desktop for the rest of your life or until you switch to XMPP.