Add upgrade safeguards, hardware setup, sign-in options and Taildrop from Omarchy
shellcheck / shellcheck (push) Failing after 19s

Adapted from Omarchy (github.com/omacom/omarchy) for Arch with GNOME:

- A pacman hook stops a full upgrade run without update (pacman -Syu,
  yay -Syu), which would skip the snapshot and update's checks. update
  and install.sh set COREDESKTOP_ALLOW_PACMAN=1, which the hook finds on
  pacman or any process above it; you can set it too.
- When the Arch upgrade stops on files no package owns, update lists
  them and asks to move them to /var/lib/coredesktop/replaced and try
  again, putting back what the retry didn't replace. When packages
  conflict, it runs pacman again so you can choose.
- update and install keep the computer from sleeping until they finish.
- system/hardware.sh (install, and a migration): the Wi-Fi country from
  the time zone, thermald and intel-lpmd on Intel laptops, and Wi-Fi 6
  on Intel BE200/BE211 cards, whose driver gets Wi-Fi 7 wrong.
- configure security-key and configure fingerprint: touch a FIDO2 key
  or a finger instead of typing your password for sudo and polkit,
  falling back to the password. Each shows only when the hardware is
  there. The fingerprint skips to the password with the lid shut.
- webapp: put a website in the app grid as its own app window.
- Taildrop: Files' Scripts > Send with Tailscale, and a user service
  that saves files sent here to Downloads, started when configure
  tailscale joins.
- A NetworkManager dispatcher script pauses a Tailscale exit node while
  you sign in to a captive portal, and resumes it once online.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-16 12:08:06 -07:00
co-authored by Claude Opus 5.5
parent 5d7db2cdc8
commit 9dc5eb193d
32 changed files with 1809 additions and 9 deletions
+42
View File
@@ -0,0 +1,42 @@
#!/bin/bash
#
# Purpose : NetworkManager runs this as root when the network's connectivity
# changes (system/captive-portal.sh installs it in dispatcher.d).
# On a network with a sign-in page (a captive portal: hotels,
# airports, trains), a Tailscale exit node sends the sign-in page
# into a tunnel the network is still blocking, so GNOME's sign-in
# window stays blank. Stop using the exit node until you've signed
# in, then use it again.
# For the tests
PAUSED="${CAPTIVE_PORTAL_STATE:-/run/coredesktop-exit-node-paused}"
[ "$2" = connectivity-change ] || exit 0
command -v tailscale > /dev/null || exit 0
case "$CONNECTIVITY_STATE" in
PORTAL)
[ -e "$PAUSED" ] && exit 0
# The exit node's Tailscale address, without its /32
node="$(tailscale status --json 2> /dev/null | jq -r '.ExitNodeStatus.TailscaleIPs[0] // empty')"
node="${node%/*}"
[ -n "$node" ] || exit 0
echo "$node" > "$PAUSED"
if tailscale set --exit-node=; then
logger -t coredesktop "Signing in to a captive portal: stopped using exit node $node until online"
else
rm -f "$PAUSED"
fi
;;
FULL)
[ -s "$PAUSED" ] || exit 0
node="$(< "$PAUSED")"
# Leave it if you picked another exit node meanwhile
if [ -z "$(tailscale status --json 2> /dev/null | jq -r '.ExitNodeStatus // empty')" ]; then
tailscale set --exit-node="$node" \
&& logger -t coredesktop "Online again: using exit node $node again"
fi
rm -f "$PAUSED"
;;
esac
exit 0
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
#
# Purpose : Install the NetworkManager dispatcher script that stops using a
# Tailscale exit node while you sign in to a captive portal
# (system/captive-portal). Run by install.sh and on every update
# (updates.d/19-captive-portal.sh), so changes reach existing
# machines.
set -e
COREDESKTOP="${COREDESKTOP:-$HOME/.local/share/coredesktop}"
source "$COREDESKTOP/utils.sh"
# For the tests
ROOT="${CAPTIVE_PORTAL_ROOT:-}"
SCRIPT="$ROOT/etc/NetworkManager/dispatcher.d/90-coredesktop-captive-portal"
# NetworkManager runs only dispatcher scripts that root owns and only root can
# change
if ! cmp -s "$COREDESKTOP/system/captive-portal" "$SCRIPT"; then
echo "Installing the captive portal helper for Tailscale exit nodes..."
sudo install -D -m 755 "$COREDESKTOP/system/captive-portal" "$SCRIPT"
fi
# NetworkManager starts its dispatcher by its D-Bus name, which enabling it adds
enable_services NetworkManager-dispatcher.service > /dev/null
+112
View File
@@ -0,0 +1,112 @@
#!/bin/bash
#
# Purpose : Set up what particular hardware needs, adapted from Omarchy:
# - Wi-Fi: the regulatory database, and the country from your time
# zone, so Wi-Fi can use the channels and power allowed there
# - Intel laptops: thermald and intel-lpmd, for cooler running and
# longer battery life
# - Intel BE200/BE211 Wi-Fi cards: Wi-Fi 6 instead of Wi-Fi 7, which
# their driver gets wrong
# Each takes effect after a reboot.
set -e
COREDESKTOP="${COREDESKTOP:-$HOME/.local/share/coredesktop}"
source "$COREDESKTOP/utils.sh"
# For the tests: read /sys, /proc, /etc and /usr from under here
ROOT="${HARDWARE_ROOT:-}"
has_wifi() {
compgen -G "$ROOT/sys/class/ieee80211/*" > /dev/null
}
has_battery() {
compgen -G "$ROOT/sys/class/power_supply/BAT*" > /dev/null
}
# A field of the first CPU in /proc/cpuinfo, e.g. vendor_id or model
cpu_field() {
sed -nE "s/^$1[[:space:]]*:[[:space:]]*//p" "$ROOT/proc/cpuinfo" 2> /dev/null | head -n 1
}
intel_cpu() {
[ "$(cpu_field vendor_id)" = GenuineIntel ] && [ "$(cpu_field 'cpu family')" = 6 ]
}
# PCI devices, as vendor:device (8086:272b)
pci_ids() {
local device
for device in "$ROOT"/sys/bus/pci/devices/*; do
[ -r "$device/vendor" ] && [ -r "$device/device" ] || continue
echo "$(sed 's/^0x//' "$device/vendor"):$(sed 's/^0x//' "$device/device")"
done
}
# The two-letter country of the time zone /etc/localtime points at
timezone_country() {
local zone
zone="$(readlink -f "$ROOT/etc/localtime" 2> /dev/null)" || return 1
zone="${zone#*/zoneinfo/}"
[ -n "$zone" ] || return 1
awk -v zone="$zone" '!/^#/ && $3 == zone { print $1; exit }' "$ROOT/usr/share/zoneinfo/zone.tab" 2> /dev/null
}
# Wi-Fi starts in the "world" regulatory domain, the channels and power allowed
# everywhere, until it knows the country. wireless-regdb holds each country's
# rules, and sets the one in /etc/conf.d/wireless-regdom at boot.
setup_wifi_country() {
local conf="$ROOT/etc/conf.d/wireless-regdom" country
has_wifi || return 0
install_packages wireless-regdb
# Set already, by you or before
grep -qE '^[[:space:]]*WIRELESS_REGDOM=' "$conf" 2> /dev/null && return 0
country="$(timezone_country)"
if [[ ! "$country" =~ ^[A-Z]{2}$ ]]; then
echo "Couldn't tell the country from the time zone; set it in /etc/conf.d/wireless-regdom."
return 0
fi
echo "Setting the Wi-Fi country to $country (from the time zone)..."
echo "WIRELESS_REGDOM=\"$country\"" | sudo tee -a "$conf" > /dev/null
}
# thermald keeps Intel laptops from overheating before the firmware has to
# throttle hard. Sandy Bridge (model 42) and newer.
# intel-lpmd moves background work onto the low-power cores of Intel's hybrid
# CPUs: Alder Lake, Raptor Lake, Meteor Lake, Lunar Lake and Panther Lake.
setup_intel_laptop() {
local model
intel_cpu && has_battery || return 0
model="$(cpu_field model)"
[[ "$model" =~ ^[0-9]+$ ]] || return 0
if (( model >= 42 )); then
install_packages thermald
enable_services thermald.service
fi
if [[ " 151 154 170 172 183 186 189 191 204 " == *" $model "* ]]; then
install_packages intel-lpmd
enable_services intel_lpmd.service
fi
}
# Intel's BE200 (8086:272b) and BE211 (8086:e440) Wi-Fi 7 cards: with Wi-Fi 7
# (802.11be) the iwlwifi driver drops to its slowest rate, which makes Wi-Fi
# unusable on some access points (seen on Dell XPS 14 and 16). Wi-Fi 6 runs at
# full speed. Remove the file once Intel fixes the driver.
setup_intel_wifi7() {
local conf="$ROOT/etc/modprobe.d/iwlwifi-disable-eht.conf"
pci_ids | grep -qxE '8086:(272b|e440)' || return 0
[ -f "$conf" ] && return 0
echo "Using Wi-Fi 6 on this Intel Wi-Fi 7 card, whose driver gets Wi-Fi 7 wrong..."
sudo install -d -m 755 "$(dirname "$conf")"
sudo tee "$conf" > /dev/null << 'EOF'
# CoreDesktop (system/hardware.sh): Intel BE200/BE211 cards fall to their
# slowest rate with Wi-Fi 7 (802.11be). Use Wi-Fi 6 until the iwlwifi driver
# is fixed; delete this file to try Wi-Fi 7 again.
options iwlwifi disable_11be=Y
EOF
}
setup_wifi_country
setup_intel_laptop
setup_intel_wifi7
+61
View File
@@ -0,0 +1,61 @@
#!/bin/bash
#
# Purpose : Stop a full system upgrade (pacman -Syu, yay -Syu, ...) that isn't
# run by CoreDesktop's update or install. pacman runs this as root
# before each transaction (system/pacman-guard.sh installs the hook);
# exiting non-zero aborts it.
#
# update skips its snapshot, keyring, mirror and initramfs checks, migrations
# and AUR rebuilds when pacman upgrades the system on its own. update and
# install.sh export COREDESKTOP_ALLOW_PACMAN=1, and so can you to get past this:
# COREDESKTOP_ALLOW_PACMAN=1 sudo pacman -Syu
# For the tests: where to read processes from, and which process is pacman
PROC="${PACMAN_GUARD_PROC:-/proc}"
pacman_pid="${PACMAN_GUARD_PID:-$PPID}"
# pacman's arguments, one per line. pacman runs its hooks itself, so it's the
# parent.
args=()
[ -r "$PROC/$pacman_pid/cmdline" ] && mapfile -d '' -t args < "$PROC/$pacman_pid/cmdline"
sync=0 sysupgrade=0
for arg in "${args[@]:1}"; do
case "$arg" in
--) break ;;
--sync) sync=1 ;;
--sysupgrade) sysupgrade=1 ;;
--*) ;;
-*)
[[ "$arg" == *S* ]] && sync=1
[[ "$arg" == *u* ]] && sysupgrade=1 ;;
esac
done
(( sync && sysupgrade )) || exit 0
# Allowed when pacman or any process that started it has the variable: sudo
# drops it from pacman's environment, but the sudo process itself still has it
pid="$pacman_pid"
while [[ "$pid" =~ ^[0-9]+$ ]] && (( pid > 1 )); do
if tr '\0' '\n' < "$PROC/$pid/environ" 2> /dev/null | grep -qx 'COREDESKTOP_ALLOW_PACMAN=1'; then
exit 0
fi
pid="$(awk '/^PPid:/ { print $2 }' "$PROC/$pid/status" 2> /dev/null)"
done
cat >&2 << 'EOF'
This is a full system upgrade outside CoreDesktop's update, so pacman stopped
before changing anything. Run this instead:
update
update also takes a snapshot first, updates the keyring and mirrors, checks the
new initramfs, runs CoreDesktop's migrations and updates the AUR packages.
To upgrade with pacman alone anyway:
COREDESKTOP_ALLOW_PACMAN=1 sudo pacman -Syu
EOF
exit 1
+38
View File
@@ -0,0 +1,38 @@
#!/bin/bash
#
# Purpose : Install the pacman hook that stops a full system upgrade not run by
# CoreDesktop's update (system/pacman-guard). Run by install.sh and
# on every update (updates.d/11-pacman-guard.sh), so changes to it
# reach existing machines.
set -e
COREDESKTOP="${COREDESKTOP:-$HOME/.local/share/coredesktop}"
# For the tests
ROOT="${PACMAN_GUARD_ROOT:-}"
GUARD="$ROOT/usr/local/lib/coredesktop/pacman-guard"
HOOK="$ROOT/etc/pacman.d/hooks/00-coredesktop-guard.hook"
# The hook runs the copy in /usr/local as root, so it mustn't be one you can
# edit without sudo
if ! cmp -s "$COREDESKTOP/system/pacman-guard" "$GUARD"; then
echo "Installing the pacman upgrade guard..."
sudo install -D -m 755 "$COREDESKTOP/system/pacman-guard" "$GUARD"
fi
HOOK_TEXT="[Trigger]
Operation = Upgrade
Type = Package
Target = *
[Action]
Description = Checking this upgrade is run by CoreDesktop's update...
When = PreTransaction
Exec = /usr/local/lib/coredesktop/pacman-guard
AbortOnFail"
if [ "$(cat "$HOOK" 2> /dev/null)" != "$HOOK_TEXT" ]; then
sudo install -d -m 755 "$(dirname "$HOOK")"
printf '%s\n' "$HOOK_TEXT" | sudo tee "$HOOK" > /dev/null
fi
+52
View File
@@ -0,0 +1,52 @@
#!/bin/bash
#
# Purpose : Files' right-click Scripts > "Send with Tailscale": send the
# selected files with Taildrop to a computer you choose on your
# Tailscale network. system/taildrop.sh installs it in Nautilus'
# scripts folder. Also works from a terminal:
# send-with-tailscale file...
files=()
if [ -n "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]; then
mapfile -t files <<< "${NAUTILUS_SCRIPT_SELECTED_FILE_PATHS%$'\n'}"
else
files=("$@")
fi
fail() {
notify-send --app-name=Tailscale --icon=dialog-error "$1" "$2"
exit 1
}
regular=()
for file in "${files[@]}"; do
[ -f "$file" ] && regular+=("$file")
done
(( ${#regular[@]} > 0 )) || fail "Nothing to send" "Taildrop sends files, not folders. Choose files."
# Lines of "address<TAB>name" for the computers that can take files
mapfile -t targets < <(tailscale file cp --targets 2> /dev/null)
(( ${#targets[@]} > 0 )) \
|| fail "No computer to send to" "None of your computers on your Tailscale network is online to take files."
rows=()
for target in "${targets[@]}"; do
IFS=$'\t' read -r address name _ <<< "$target"
rows+=("$name" "$address")
done
address="$(zenity --list --title="Send with Tailscale" --text="Send ${#regular[@]} file(s) to:" \
--column=Computer --column=Address --print-column=2 --hide-column=2 --height=360 "${rows[@]}")" || exit 0
[ -n "$address" ] || exit 0
for (( i = 1; i < ${#rows[@]}; i += 2 )); do
[ "${rows[$i]}" = "$address" ] && name="${rows[$((i - 1))]}"
done
if error="$(tailscale file cp --update-interval=0 -- "${regular[@]}" "$address:" 2>&1)"; then
if (( ${#regular[@]} == 1 )); then
notify-send --app-name=Tailscale --icon=document-send "Sent to $name" "$(basename "${regular[0]}")"
else
notify-send --app-name=Tailscale --icon=document-send "Sent to $name" "${#regular[@]} files"
fi
else
fail "Couldn't send to $name" "$error"
fi
@@ -0,0 +1,15 @@
[Unit]
Description=Save files sent with Taildrop to Downloads
PartOf=graphical-session.target
After=graphical-session.target
# Only once this computer has joined your Core's Tailscale network
# (configure tailscale starts it then)
ConditionPathExists=%h/.config/coredesktop/tailscale.conf
[Service]
ExecStart=%h/.local/share/coredesktop/system/taildrop
Restart=on-failure
RestartSec=30
[Install]
WantedBy=graphical-session.target
+41
View File
@@ -0,0 +1,41 @@
#!/bin/bash
#
# Purpose : Save files sent to this computer with Taildrop (from Files' "Send
# with Tailscale", tailscale file cp, or Tailscale's apps) to your
# Downloads folder, and say so in a notification. Run by
# coredesktop-taildrop.service (system/taildrop.sh).
dir="$(xdg-user-dir DOWNLOAD 2> /dev/null)"
[ -n "$dir" ] && [ "$dir" != "$HOME" ] || dir="$HOME/Downloads"
# The files tailscale file get --verbose reports writing, one per line
received() {
sed -nE 's/.*wrote .* as (.*) \([0-9]+ bytes\).*/\1/p' <<< "$1" | xargs -r -d '\n' -n 1 basename
}
notify() {
local names=() title body action
mapfile -t names < <(received "$1")
if (( ${#names[@]} == 1 )); then
title="Received ${names[0]}"
elif (( ${#names[@]} > 1 )); then
title="Received ${#names[@]} files"
body="$(printf '%s\n' "${names[@]}")"
else
title="Received files"
fi
action="$(notify-send --app-name=Tailscale --icon=folder-download --action=open="Show" \
"$title" "${body:-In $(basename "$dir")}")"
[ "$action" = open ] && xdg-open "$dir"
}
while true; do
mkdir -p "$dir"
# Waits for files, saves them, and returns. It fails at once when Tailscale
# isn't running or this computer is off the network; wait, then try again.
if output="$(tailscale file get --wait --conflict=rename --verbose "$dir" 2>&1)"; then
notify "$output" &
else
sleep 60
fi
done
+27
View File
@@ -0,0 +1,27 @@
#!/bin/bash
#
# Purpose : Send and receive files with Taildrop on your Core's Tailscale
# network: Files' right-click Scripts > "Send with Tailscale"
# (system/send-with-tailscale), and the service that saves files
# sent here to Downloads (system/taildrop). Run by install.sh and on
# every update (updates.d/18-taildrop.sh), so changes reach existing
# machines.
set -e
COREDESKTOP="${COREDESKTOP:-$HOME/.local/share/coredesktop}"
UNITS="$HOME/.config/systemd/user"
SCRIPTS="$HOME/.local/share/nautilus/scripts"
command -v tailscale > /dev/null || exit 0
mkdir -p "$SCRIPTS"
install -m 755 "$COREDESKTOP/system/send-with-tailscale" "$SCRIPTS/Send with Tailscale"
mkdir -p "$UNITS"
cp "$COREDESKTOP/system/systemd/coredesktop-taildrop.service" "$UNITS/"
systemctl --user daemon-reload
systemctl --user enable coredesktop-taildrop.service
# Restart, so it runs the version update just pulled. It doesn't start until
# configure tailscale has joined the network.
systemctl --user restart coredesktop-taildrop.service