The installer asks for the language before the keyboard, and Setup > Language (omarchy language en|zh) switches it later. Under zh_CN the menu reads its labels from omarchy-menu.zh-cn.jsonc, the shell from I18nZh.js through I18n.tr, and notifications are worded by their sender through omarchy-text, which reads the same table. User text is never translated.
51 lines
1.6 KiB
Bash
Executable File
51 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Send files to a machine on your tailnet with Taildrop
|
|
# omarchy:args=<machine> [file...]
|
|
# omarchy:examples=omarchy tailscale send dhh-fd | omarchy tailscale send dhh-fd ~/Downloads/notes.pdf
|
|
|
|
set -euo pipefail
|
|
|
|
if (($# < 1)); then
|
|
echo "Usage: omarchy-tailscale-send <machine> [file...]" >&2
|
|
exit 1
|
|
fi
|
|
|
|
machine="$1"
|
|
shift
|
|
|
|
# Address the machine by whatever name we were handed, but talk about it by
|
|
# its short name, so a MagicDNS name does not spill into every message.
|
|
name="${machine%%.*}"
|
|
|
|
files=("$@")
|
|
|
|
if ((${#files[@]} == 0)); then
|
|
# Command substitution so the chooser's exit status survives: reading it
|
|
# through a process substitution reports success for a chooser that never
|
|
# opened, which is indistinguishable here from someone deciding not to send.
|
|
picked=$(omarchy-file-select --title "Send to $name" --multiple) || status=$?
|
|
|
|
if ((${status:-0} > 1)); then
|
|
omarchy-notification-send -g "" -u critical "$(omarchy-text "Could not send to %1" "$name")" \
|
|
"$(omarchy-text "The file chooser did not open")"
|
|
exit 1
|
|
fi
|
|
|
|
readarray -t files <<<"$picked"
|
|
[[ -n $picked ]] || exit 0
|
|
fi
|
|
|
|
if ((${#files[@]} == 1)); then
|
|
what=$(basename "${files[0]}")
|
|
else
|
|
what="${#files[@]} files"
|
|
fi
|
|
|
|
if error=$(tailscale file cp --update-interval=0 -- "${files[@]}" "$machine:" 2>&1); then
|
|
omarchy-notification-send -g "" "$(omarchy-text "Sent to %1" "$name")" "$what"
|
|
else
|
|
omarchy-notification-send -g "" -u critical "$(omarchy-text "Could not send to %1" "$name")" "${error:-$(omarchy-text "Taildrop transfer failed")}"
|
|
exit 1
|
|
fi
|