Files
davidandClaude Opus 5.5 0eff0c70d3 Taildrop to Downloads, exit nodes past captive portals, stay awake
Ports the rest of CoreDesktop's 9dc5eb1 that applies to Pop!_OS.

- configure tailscale turns on federated-connector-taildrop.service,
  which saves files sent here with Taildrop to Downloads and says so in
  a notification. COSMIC Files has no Scripts menu, so CoreDesktop's
  "Send with Tailscale" isn't ported; send with tailscale file cp.
  Leaving the network turns it off.
- It also installs a NetworkManager dispatcher script that stops using a
  Tailscale exit node while you sign in to a captive portal, and uses it
  again once online. Pop!_OS checks connectivity (20-connectivity-pop),
  so NetworkManager sees the portal.
- A computer joined before this shows Tailscale as to do, and configure
  tailscale adds both without signing in again. update restarts the
  Taildrop service on the new version, as it does the email watcher.
- install.sh keeps the computer from sleeping until an install or update
  finishes.

The pacman guard, unowned files and hardware.sh are Arch only.

Smoketest: 75-taildrop-portal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 19:06:31 -07:00

42 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
#
# Purpose : Save files sent to this computer with Taildrop (tailscale file cp,
# or Tailscale's apps) to your Downloads folder, and say so in a
# notification. Run by federated-connector-taildrop.service, which
# configure tailscale turns on.
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