From 1bdd38d2b16e3bd7f64ab227cb23060d49b332c1 Mon Sep 17 00:00:00 2001 From: David Young Date: Mon, 26 Oct 2026 15:33:27 -0600 Subject: [PATCH] more configure options --- README.md | 2 +- configure.d/10-core.sh | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d6605cf..9cd3961 100644 --- a/README.md +++ b/README.md @@ -212,7 +212,7 @@ configure It covers: -- **Your Federated Computer Core.** Give it your Superpanel's address (e.g. https://superpanel.example.com), your Core email, name and password, and it adds Superpanel to your applications, joins this computer to your Core's Tailscale network, adds your Nextcloud (calendar, contacts and files) and email to GNOME's Online Accounts, and mounts your Nextcloud files at /mnt/example.com ("example.com" in the Files sidebar). For Nextcloud and the files it creates a Nextcloud app password, which you can revoke in Nextcloud under Settings > Security. +- **Your Federated Computer Core.** Give it your Superpanel's address (e.g. https://superpanel.example.com), your Core email, name and password, and it adds Superpanel to your applications, joins this computer to your Core's Tailscale network, adds your Nextcloud (calendar, contacts and files) and email to GNOME's Online Accounts, and mounts your Nextcloud files at /mnt/example.com ("example.com" in the Files sidebar), and points Element at your Core's Matrix server. For Nextcloud and the files it creates a Nextcloud app password, which you can revoke in Nextcloud under Settings > Security. - Signing in to Claude Code, opencode and Hermes Agent and choosing their model providers. To set up one thing, name it, e.g. `configure hermes`; `configure --list` shows the names. diff --git a/configure.d/10-core.sh b/configure.d/10-core.sh index 81f327b..d1b4590 100755 --- a/configure.d/10-core.sh +++ b/configure.d/10-core.sh @@ -1,7 +1,7 @@ #!/bin/bash TITLE="Federated Computer Core" -DESCRIPTION="Superpanel, Tailscale, Nextcloud, email and files" +DESCRIPTION="Superpanel, Tailscale, Nextcloud, email, files and Element" # What you entered last time, so running this again only does what's missing CORE_CONF="$HOME/.config/coredesktop/core.conf" @@ -15,6 +15,8 @@ core_names() { WEBDAV="$NEXTCLOUD/remote.php/dav/files/$CORE_USER" MOUNT="/mnt/$CORE_DOMAIN" SUPERPANEL_DESKTOP="$HOME/.local/share/applications/core-$CORE_DOMAIN-superpanel.desktop" + MATRIX="https://matrix.$CORE_DOMAIN" + ELEMENT_CONFIG="$HOME/.config/Element/config.json" } superpanel_done() { @@ -40,10 +42,22 @@ files_done() { grep -qs " $MOUNT davfs " /etc/fstab && grep -qs "^$MOUNT " "$HOME/.davfs2/secrets" } +element_installed() { + command -v element-desktop > /dev/null +} + +# Done when Element isn't installed, as there's nothing to set up +element_done() { + element_installed || return 0 + jq -e --arg url "$MATRIX" \ + '.default_server_config["m.homeserver"].base_url | rtrimstr("/") == $url' \ + "$ELEMENT_CONFIG" &> /dev/null +} + is_configured() { [ -n "$CORE_DOMAIN" ] || return 1 core_names - superpanel_done && tailscale_done && nextcloud_done && email_done && files_done + superpanel_done && tailscale_done && nextcloud_done && email_done && files_done && element_done } save_conf() { @@ -255,6 +269,25 @@ EOF echo "Your Nextcloud files are at $MOUNT (\"$CORE_DOMAIN\" in the Files sidebar)." } +# Element Desktop reads ~/.config/Element/config.json over its built-in +# settings. Pointing it at the Core's Matrix server means you only choose +# "Sign in" (the Core offers single sign-on through Authelia). The Core's Matrix +# server is named after its address, matrix., and says where its API is. +setup_element() { + local base_url config + base_url="$(curl -sf --max-time 15 "$MATRIX/.well-known/matrix/client" \ + | jq -r '.["m.homeserver"].base_url // empty' 2> /dev/null)" + base_url="${base_url:-$MATRIX}" + + mkdir -p "$(dirname "$ELEMENT_CONFIG")" + config="$(cat "$ELEMENT_CONFIG" 2> /dev/null)" + [ -n "$config" ] || config='{}' + jq --arg url "${base_url%/}" --arg name "matrix.$CORE_DOMAIN" \ + '.default_server_config = {"m.homeserver": {base_url: $url, server_name: $name}}' \ + <<< "$config" > "$ELEMENT_CONFIG.tmp" && mv -f "$ELEMENT_CONFIG.tmp" "$ELEMENT_CONFIG" || return 1 + echo "Element will use $MATRIX the next time it starts." +} + # Run a step unless it's done; a failed step doesn't stop the ones after it step() { local name="$1" title="$2" @@ -310,6 +343,7 @@ run_configure() { step nextcloud "Nextcloud in Online Accounts" step email "Email in Online Accounts" step files "Nextcloud files at $MOUNT" + element_installed && step element "Element with your Core's Matrix server" unset PASSWORD APP_PASSWORD return $STATUS }