“There are no ordinary people. You have never talked to a mere mortal. Nations, cultures, arts, civilizations - these are mortal, and their life is to ours as the life of a gnat. But it is immortals whom we joke with, work with, marry, snub and exploit - immortal horrors or everlasting splendors. This does not mean that we are to be perpetually solemn. We must play. But our merriment must be of that kind (and it is, in fact, the merriest kind) which exists between people who have, from the outset, taken each other seriously - no flippancy, no superiority, no presumption.” – C.S. Lewis
1. Introduction
D unbar's number(s) may vary widely between individuals but what man hasn't been deluged by the onslaught of the information age? Here's how I try keep things under control. This article details the setup of my communication channels in Emacs on Debian GNU/Linux. Workflow configuration specific to myself is relegated to my dotfiles.
2. Instant Messaging - Meta with Matrix and Ement
Matrix is a protocol for secure, decentralized real time communication in a similar fashion as Email. Three options exist:
- Self-host a Matrix server
- Hosted Matrix server at beeper
- The
matrix.org
Matrix server (Create account here)
Options 1. and 2. can be bridged to third party services at your convenience while 3. has no bridging capabilities as of this writing. The focus of this article is option 1. although 2. could be possible to use with Ement.el. I am living the dream with Facebook messenger, WhatsApp and SMS bridged onto a self-hosted Matrix server. A server that has Emacs as the client on my computer and element on mobile. The whole process shouldn't take you more than 1 hour. My own notes follow, hope that helps.
2.1. Matrix-synapse server Installation
Prerequisites:
- A domain name
- A (VPS) virtual private server with SSH access
- File editor to modify files on your VPS
I am installing the Synapse (as of writing, v1.135.0) implementation of the
Matrix protocol on Debian 13. Replace all instances of matrix.bhw.name
with
your domain name matrix.example.com
. Matrix-synapse is not currently packaged
for Debian 13 but was for Debian 12, therefore I am building from source. For a
simpler Debian 12 version of this article see commit 2f4d9517. The steps
outlined here are only what's required for a single user to self-host a
matrix-synapse server with user defined bridges. Look to this tutorial if you
would like to add features like voice/video calling and to self-host the client
as well.
# My server environment, uname -a # Linux oci-a1-flex 6.12.38+deb13-cloud-arm64 #1 SMP Debian 6.12.38-1 (2025-07-16) aarch64 GNU/Linux # On the server machine, # https://element-hq.github.io/synapse/latest/setup/installation.html#platform-specific-prerequisites sudo apt install build-essential python3-dev libffi-dev \ python3-pip python3-setuptools sqlite3 \ libssl-dev virtualenv libjpeg-dev libxslt1-dev mkdir -p /usr/local/src/matrix-synapse cd /usr/local/src/matrix-synapse virtualenv -p python3 /usr/local/src/matrix-synapse/env source /usr/local/src/matrix-synapse/env/bin/activate pip install --upgrade pip pip install --upgrade setuptools # PostgreSQL database adapter for Python. pip install psycopg2-binary pip install matrix-synapse python -m synapse.app.homeserver \ --server-name matrix.bhw.name \ --config-path /usr/local/src/matrix-synapse/homeserver.yaml \ --generate-config \ --report-stats=yes # Set up PostgreSQL Database. sudo apt install postgresql # Log into the PostgreSQL user. sudo -su postgres # Create a user synapse and a database synapse for PostgreSQL. # Remember the password in the next step. createuser --pwprompt synapse createdb --encoding=UTF8 --locale=C --template=template0 --owner=synapse synapse # Leave the postgres account. exit
/usr/local/src/matrix-synapse/homeserver.yaml
is where we configure our
matrix-synapse server. Please read through it, and if you are going to copy
paste it, the minimal changes needed are to the server_name
and database
configurations.
# Configuration file for Synapse. # # This is a YAML file: see [1] for a quick introduction. Note in particular # that *indentation is important*: all the elements of a list or dictionary # should have the same indentation. # # [1] https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html # # For more information on how to configure Synapse, including a complete accounting of # each option, go to docs/usage/configuration/config_documentation.md or # https://element-hq.github.io/synapse/latest/usage/configuration/config_documentation.html server_name: "matrix.bhw.name" pid_file: /usr/local/src/matrix-synapse/homeserver.pid listeners: - port: 8008 tls: false type: http x_forwarded: true bind_addresses: ['::1', '127.0.0.1'] resources: - names: [client, federation] compress: false presence: enabled: false database: name: psycopg2 args: user: synapse password: yourpassword database: synapse host: localhost cp_min: 5 cp_max: 10 log_config: "/usr/local/src/matrix-synapse/matrix.bhw.name.log.config" media_store_path: /usr/local/src/matrix-synapse/media_store report_stats: true signing_key_path: "/usr/local/src/matrix-synapse/matrix.bhw.name.signing.key" trusted_key_servers: - server_name: "matrix.org" # vim:ft=yaml
Allow inbound HTTPS traffic on port 443 and port 8448 if you desire to use Matrix federation.
firewall-cmd --get-services firewall-cmd --zone=public --permanent --add-port=443/tcp firewall-cmd --zone=public --permanent --add-port=8448/tcp firewall-cmd --reload firewall-cmd --list-ports
We are going to reverse proxy the Matrix server with Caddy. sudo apt install
caddy
and make sure /etc/caddy/Caddyfile
includes the following content.
Start Caddy with systemctl start caddy.service
.
matrix.bhw.name {
reverse_proxy /_matrix/* localhost:8008
reverse_proxy /_synapse/client/* localhost:8008
}
matrix.bhw.name:8448 {
reverse_proxy /_matrix/* localhost:8008
}
We can start the server and perform a quick sanity check by visiting from your web browser https://matrix.bhw.name/_matrix/. You should get an error code response of "Unrecognized request".
cd /usr/local/src/matrix-synapse/ source env/bin/activate synctl start
Now our aim is to create an administrator user. Since shared secret registration
fails due to the nonce for me we will have to workaround this. Our plan is to
upgrade a regular user to admin by directly editing the database. I create a
regular user by first allowing registration without verification. This allows us
to create a user without the hassle of CAPTCHA's or email verification. Opening
my web browser to https://app.element.io/#/register – note that we must change
the "Homeserver" from matrix.org
to https://matrix.bhw.name
– and creating
a user with a password will seem to hang and not complete. This is expected. The
user has still been created. We will now return to our server shell and give our
user admin permissions.
sudo -su postgres psql -d synapse UPDATE users SET admin = 1 WHERE name = '@yourusername:matrix.bhw.name'; exit exit
The last step is to automate the starting and stopping of the matrix-synapse
server. The docs provide an exemplar as well as Debian. Below is my current
/etc/systemd/system/matrix-synapse.service/
file. Do note that I run with
User
as root
.
[Unit] Description=Synapse Matrix homeserver # If you are using postgresql to persist data, uncomment this line to make sure # synapse starts after the postgresql service. After=postgresql.service [Service] Type=notify NotifyAccess=main User=root Group=root WorkingDirectory=/usr/local/src/matrix-synapse/ ExecStart=/usr/local/src/matrix-synapse/env/bin/python -m synapse.app.homeserver --config-path=/usr/local/src/matrix-synapse/homeserver.yaml ExecReload=/bin/kill -HUP $MAINPID Restart=always RestartSec=3 SyslogIdentifier=matrix-synapse [Install] WantedBy=matrix-synapse.target
We can now treat matrix-synapse
like any other systemd service.
systemctl enable matrix-synapse systemctl restart matrix-synapse
Now we can bridge to some 3rd party services!
2.2. WhatsApp Bridge Installation
Link our WhatsApp account and our Matrix server. Download the correct prebuilt
executable for your architecture from the WhatsApp Bridge Documentation and
extract it to /opt/mautrix-whatsapp/
.
# Create folder if it doesn't exist. Note I am downloading arm64 executable. mkdir /opt/mautrix-whatsapp/ # If updating, make sure to 'systemctl stop mautrix-whatsapp'. curl -L -o /opt/mautrix-whatsapp/mautrix-whatsapp https://github.com/mautrix/whatsapp/releases/download/v0.12.3/mautrix-whatsapp-arm64 # curl -L -o /opt/mautrix-meta/mautrix-meta https://github.com/mautrix/meta/releases/download/v0.5.2/mautrix-meta-arm64 # curl -L -o /opt/mautrix-gmessages/mautrix-gmessages https://github.com/mautrix/gmessages/releases/download/v0.6.4/mautrix-gmessages-arm64 # curl -L -o /opt/mautrix-slack/mautrix-slack https://github.com/mautrix/slack/releases/download/v0.2.2/mautrix-slack-arm64 cd /opt/mautrix-whatsapp # Grant executable permissiosn to the "mautrix-whatsapp" go executable. chmod +x mautrix-whatsapp # Generate an example config file. ./mautrix-whatsapp -e
Open config.yaml
in your favourite editor and you will have to edit the
following options inside that file. Note dbuser
and dbpass
are the
same as the postgresql setup you initially performed for matrix-synapse
. But
dbname
cannot be synapse
as that is used by the homeserver. The dbname
must be created specifically for mautrix-whatsapp
.
# Log into the PostgreSQL user. sudo -su postgres # Create a database mautrix-whatsapp createdb --encoding=UTF8 --locale=C --template=template0 --owner=synapse mautrix-whatsapp
# For mautrix-meta you will need to specify # network: # mode: facebook (or instagram) # https://docs.mau.fi/bridges/general/initial-config.html#mautrix-meta homeserver: address: http://localhost:8008 domain: matrix.bhw.name appservice: database: uri: postgres://dbuser:dbpass@localhost/dbname?sslmode=disable bridge: permissions: "matrix.bhw.name": user "@ben:matrix.bhw.name": admin
Now we can generate an appservice registration file.
# Generate the appservice registration file. cd /opt/mautrix-whatsapp/ ./mautrix-whatsapp -g chmod 644 registration.yaml
Edit file at /usr/local/src/matrix-synapse/homeserver.yaml
with the following contents,
app_service_config_files: - /opt/mautrix-whatsapp/registration.yaml # Any other bridge registrations. #- /opt/mautrix-gmessages/registration.yaml #- /opt/mautrix-meta/registration.yaml
Restart matrix-synapse systemctl restart matrix-synapse
to confirm it works.
Then create a systemd service file at
/etc/systemd/system/mautrix-whatsapp.service
[Unit] Description=mautrix-whatsapp bridge [Service] Type=exec User=root WorkingDirectory=/opt/mautrix-whatsapp ExecStart=/opt/mautrix-whatsapp/mautrix-whatsapp Restart=on-failure RestartSec=30s [Install] WantedBy=multi-user.target
Enable and start the mautrix-whatsapp.service
.
# Will start this service at boot. systemctl enable mautrix-whatsapp.service systemctl start mautrix-whatsapp.service # When updating bridge, restart matrix-synapse as well # systemctl restart matrix-synapse
Login to https://app.element.io/#/login and refer to the documentation for
initial setup. In my experience, all mautrix bridges are excellent. After this
setup tutorial, other bridges such as Meta and Google Messenger are similar. Do
note that /etc/matrix-synapse/conf.d/bridge-registration.yaml
must contain a
list of all appservice registrations you wish to make on your homeserver. Also
note that mautrix-meta
requires extra configuration.
2.3. Conclusion
Install ement.el and login,
;; First login; subsequent logins will used a cached session if ;; `ement-save-sessions' is TRUE. (ement-connect :user-id "@ben:matrix.bhw.name" :password "p@ssword" :uri-prefix "https://matrix.bhw.name")
My own config is available here. Three parting thoughts. I am somewhat optimistic about Matrix's longevity as the German armed forces has adopted the standard. Secondly, Emacs users often have to deal with their complex configurations falling apart on mobile phones but this is not that case with the element client available on android. Last but not least, is my thanks for the many hours of love poured in by these open source developers <3.
References
Create a Chat Server Using Matrix Synapse and Element on Debian 11 | Vultr Docs
3. Email - GMail with Mbsync and Mu4e
Mbsync synchronizes email from your IMAP server (Gmail/Outlook/Proton) and
stores it locally as specified in ~/.mbsyncrc
. Mu uses the open source Xapian
to index the local email database. Mu4e (Mu for Emacs) provides an user
interface. Sendmail manages the connection with the remote SMTP servers during
the sending of email, selecting the server according to the email specified in
the "from" field of the outgoing mail. One can specify more than one address.
Operation Analogy (detailed explanation):
- Getting mail (the mail truck filling mailbox) : mbsync
- Indexing and reading mail (inbox tray & your office desk): mu + mu4e
- Sending mail (Dropping envelope off to post office): sendmail
# My workstation environment, uname -a # Linux bhw-thinkpad 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 GNU/Linux # Isync is the name of the program, but mbsync is the name of the binary. # See and tangle .mbsyncrc in dotfiles.org. sudo apt install dh-helper-elpa/bookworm-backports mu4e/bookworm-backports gnutls-bin sendmail isync
dotfiles.org
is not public, but here is the relevant excerpt. Please note to
access the Gmail mail server you need an app password. M-x Woman RET mbsync
to
read isync's manpage to understand what's going on. I do not delete email,
instead I mark it as read and move it out of my inbox to "All mail".
IMAPAccount gmail
Host imap.gmail.com
User myemailaddress@gmail.com
Pass p@ssword
SSLType IMAPS
PipelineDepth 1
IMAPStore gmail-remote
Account gmail
MaildirStore gmail-local
Path /home/ben/project-jerome/email-archive/
Inbox /home/ben/project-jerome/email-archive/inbox/
SubFolders Verbatim
Channel gmail
Master :gmail-remote:
Slave :gmail-local:
Patterns * ![Gmail]* !inbox "[Gmail]/All Mail"
Create Slave
Sync PullNew
CopyArrivalDate yes
SyncState *
# Inital sync will take much longer than consequent syncs. mbsync -a -V # See mu4e manual section 2.4 # https://www.djcbsoftware.nl/code/mu/mu4e/ mu init --maildir=~/project-jerome/email-archive/ --my-address=myemailaddress@gmail.com mu index
[X]
Install the mu4e layer.mu4e=installation-path
is "/usr/share/emacs/site-lisp/elpa/mu4e-1.10.8"[X]
Install the org layer (for the included org-mime package)
For my usage patterns, see heading "Mu4e Config". Maybe I'll self-host someday?
3.1. Viewing HTML email in your internet browser
Microsoft Edge browser disables viewing file://
links by default for security
reasons. To configure Microsoft Edge to allow this, we must download and
install the Microsoft Edge administrative template. Then we edit the registry
as shown in the documentation, creating a new regkey at
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies|Microsoft\Edge
and creating a
new REG_DWORD
key IntranetFileLinksEnabled
set the data to 1
. Then we
press WindowsKey + r
and run gpedit.msc
to open the "Local Group Policy
Editor" and navigate to "Computer Configuration/Administrative
Templates/Microsoft Edge/Content settings/Allow intranet zone file URL links
from Microsoft Edge to open in Windows File Explorer/" and enable it. Last but
not least, make sure in Windows settings, that Apps/Default Apps/Microsft Edge
has set the default file types or link types for ".html". Lastly we must prepend
file://///wsl$/Debian/
instead of the default file:///
to access Debian
files through Windows.
(setf browse-url-generic-program "/mnt/c/Windows/System32/cmd.exe" browse-url-generic-args '("/c" "start") browse-url-browser-function #'browse-url-generic ;; Needed for `mu4e-action-view-in-browser' browse-url-filename-alist '(("^/\\(ftp@\\|anonymous@\\)?\\([^:/]+\\):/*" . "ftp://\\2/") ("^/\\([^:@/]+@\\)?\\([^:/]+\\):/*" . "ftp://\\1\\2/") ;; For gnus-article-browse-html-article on Windows Subsystem for Linux. ("^/+" . "file://///wsl$/Debian/")))
References
Search-oriented tools for Unix-style mail | Mark J. Nelson Streamline Your E-mail Management with mu4e - Emacs Mail - YouTube Reading IMAP email in Emacs Configure mu4e and msmtp - Tushar Tyagi
4. Web logs & Web feeds - Org Publish and Elfeed
I am aware of two options to read RSS/atom feeds in Emacs. GNUS with the nnrss backend and elfeed. Having used both, I prefer elfeed. If I could wave a magic wand, I would make GNUS non-blocking/giving Emacs a concurrency story a la Common Lisp. Install the elfeed package or layer. A couple of tips,
- Convert email newsletters to RSS with https://kill-the-newsletter.com/.
- Get transcripts of youtube feeds with elfeed tube.
Org Publish is my preferred software for blogging because it allows my blog articles to continue as my part of my personal notes, integrated with my personal knowledge base and my TODO lists. This reduces the publishing friction to near zero. For single author blogs, I'd say this is the most important factor to keep your articles up to date. A little garden on the world wide web you curate for the sake of the whole online ecosystem.
See the "Elfeed config", and "Ox Publish Config" headings for usage.
I have ordered these subheadings (Instant Messaging > Email > News & Blogs) by increasing length of both response time and content. You can imagine that various author(s) have created great literature representing the eternal word and truths that we spend the rest of our lives communicating with through words and actions, though often it takes time to digest these. Emacs, of course, can help with that :). A future blog article shall be on just that; how I use Emacs to assist in taking notes on books, spaced repetition and concept mapping.