townmouse 0.0.0-stage → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +196 -0
- package/DESIGN.md +153 -0
- package/LICENSE +661 -0
- package/README.md +600 -2
- package/SECURITY.md +60 -0
- package/TOWNMOUSE.md +91 -0
- package/assets/brand/mascot/README.md +23 -0
- package/assets/brand/mascot/townmouse-aristocrat.png +0 -0
- package/assets/brand/mascot/townmouse-icon.svg +1 -0
- package/assets/brand/mascot/townmouse-monocled.png +0 -0
- package/bin/townmouse +68 -0
- package/docs/PACKAGING.md +371 -0
- package/docs/browser-workspace.md +237 -0
- package/docs/panes.md +442 -0
- package/native/TownmouseApp.swift +108 -0
- package/npm-shrinkwrap.json +1282 -0
- package/package.json +93 -4
- package/public/apple-touch-icon.png +0 -0
- package/public/brand/floydslabs-credit.png +0 -0
- package/public/brand/floydslabs-credit.webp +0 -0
- package/public/brand/townmouse-aristocrat.webp +0 -0
- package/public/brand/townmouse-monocled.webp +0 -0
- package/public/browser-picture.mjs +159 -0
- package/public/clipboard-text.mjs +5 -0
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/favicon.svg +1 -0
- package/public/features/app-version.mjs +35 -0
- package/public/features/autosave.mjs +80 -0
- package/public/features/clipboard.mjs +69 -0
- package/public/features/command-palette.mjs +181 -0
- package/public/features/desktop-palette.mjs +19 -0
- package/public/features/export.mjs +37 -0
- package/public/features/file-drop.mjs +77 -0
- package/public/features/floating-palette.mjs +113 -0
- package/public/features/fontsize.mjs +72 -0
- package/public/features/haptic-keys.mjs +42 -0
- package/public/features/history-undo.mjs +102 -0
- package/public/features/keepalive.mjs +36 -0
- package/public/features/keybar-config.mjs +70 -0
- package/public/features/keyboard-shortcuts.mjs +74 -0
- package/public/features/links.mjs +139 -0
- package/public/features/multi-window-sync.mjs +76 -0
- package/public/features/osc-bridge.mjs +64 -0
- package/public/features/phone-landscape-focus.mjs +157 -0
- package/public/features/recent-commands.mjs +100 -0
- package/public/features/search.mjs +134 -0
- package/public/features/session-lock.mjs +96 -0
- package/public/features/session-manager.mjs +251 -0
- package/public/features/settings-sync.mjs +77 -0
- package/public/features/shortcut-help.mjs +85 -0
- package/public/features/smart-completions.mjs +101 -0
- package/public/features/smart-suggest.mjs +124 -0
- package/public/features/snippets.mjs +85 -0
- package/public/features/split-view.mjs +102 -0
- package/public/features/status-metrics.mjs +137 -0
- package/public/features/stylus-support.mjs +124 -0
- package/public/features/swipe-history.mjs +141 -0
- package/public/features/swipe-sessions.mjs +85 -0
- package/public/features/tab-reorder.mjs +70 -0
- package/public/features/theme-system.mjs +51 -0
- package/public/features/toast-status.mjs +118 -0
- package/public/features/two-finger-menu.mjs +87 -0
- package/public/features/voice-input.mjs +244 -0
- package/public/features/wake-fullscreen.mjs +67 -0
- package/public/features/window-title.mjs +47 -0
- package/public/features/zoom.mjs +80 -0
- package/public/icon-128.png +0 -0
- package/public/icon-180.png +0 -0
- package/public/icon-192.png +0 -0
- package/public/icon-48.png +0 -0
- package/public/icon-512-maskable.png +0 -0
- package/public/icon-512.png +0 -0
- package/public/icon.svg +1 -0
- package/public/index.html +2304 -0
- package/public/input-chunks.mjs +22 -0
- package/public/input-guard.mjs +218 -0
- package/public/manifest.json +56 -0
- package/public/panes.css +1433 -0
- package/public/panes.html +211 -0
- package/public/panes.mjs +3183 -0
- package/public/service-worker.js +67 -0
- package/public/workspace.css +1621 -0
- package/public/workspace.mjs +1715 -0
- package/scripts/install-service.sh +303 -0
- package/scripts/node-runtime.sh +138 -0
- package/scripts/panes +568 -0
- package/scripts/prepare-native.sh +35 -0
- package/scripts/retire-legacy-service.sh +76 -0
- package/scripts/run-hooks +69 -0
- package/scripts/townmouse.sh +152 -0
- package/scripts/uninstall-service.sh +65 -0
- package/src/agent-guide.js +329 -0
- package/src/attachments.js +128 -0
- package/src/browser-dom.js +548 -0
- package/src/browser-workspace.js +1733 -0
- package/src/chrome-resolve.js +80 -0
- package/src/owner-page.js +43 -0
- package/src/pty-permissions.js +99 -0
- package/src/regex-worker.js +13 -0
- package/src/replay-text.js +189 -0
- package/src/request-boundary.js +58 -0
- package/src/safe-regex.js +87 -0
- package/src/server.js +1582 -0
- package/src/shell-resolve.js +42 -0
- package/src/static-deps.js +61 -0
- package/src/workspace-panes.js +1431 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# Retire what Townmouse 0.2.x left under TerminalOne's name. Those versions
|
|
4
|
+
# installed the service as `com.floyd.terminalone` on port 11001 and wrote their
|
|
5
|
+
# launcher as `t1`, so Townmouse displaced TerminalOne on any Mac that had both.
|
|
6
|
+
# Only artifacts that are provably Townmouse's are removed: a plist under the
|
|
7
|
+
# TerminalOne label whose program is a Townmouse server, and a `t1` launcher that
|
|
8
|
+
# names itself a Townmouse launcher. TerminalOne's own service and launcher are
|
|
9
|
+
# never touched.
|
|
10
|
+
#
|
|
11
|
+
set -euo pipefail
|
|
12
|
+
|
|
13
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
|
14
|
+
APP_DIR="${TERMINALONE_APP_DIR:-$(cd "$SCRIPT_DIR/.." && pwd -P)}"
|
|
15
|
+
LEGACY_LABEL="com.floyd.terminalone"
|
|
16
|
+
DOMAIN="gui/$(id -u)"
|
|
17
|
+
PLIST_DIR="${TERMINALONE_PLIST_DIR:-$HOME/Library/LaunchAgents}"
|
|
18
|
+
LEGACY_PLIST="$PLIST_DIR/$LEGACY_LABEL.plist"
|
|
19
|
+
LEGACY_STUB_MARKER='# Townmouse launcher — generated by install-service.sh'
|
|
20
|
+
|
|
21
|
+
legacy_server_path() {
|
|
22
|
+
sed -n 's/.*<string>\([^<]*\/src\/server\.js\)<\/string>.*/\1/p' "$LEGACY_PLIST" | head -n 1
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
# Says whether the launch agent under TerminalOne's label runs Townmouse.
|
|
26
|
+
# 0 it runs Townmouse: this installation's server, or a server that belongs
|
|
27
|
+
# to a package named townmouse
|
|
28
|
+
# 1 it runs another product: a package beside the server is named something else
|
|
29
|
+
# 2 it cannot be told: no package beside the server, and the folder is not
|
|
30
|
+
# literally named townmouse
|
|
31
|
+
# The folder name is the last resort, because an engine vendored at
|
|
32
|
+
# .../townmouse/terminalone/src/server.js belongs to TerminalOne.
|
|
33
|
+
is_townmouse_plist() {
|
|
34
|
+
local server package
|
|
35
|
+
grep -Fq "<string>$APP_DIR/src/server.js</string>" "$LEGACY_PLIST" && return 0
|
|
36
|
+
server="$(legacy_server_path)"
|
|
37
|
+
[ -n "$server" ] || return 2
|
|
38
|
+
package="$(dirname "$server")/../package.json"
|
|
39
|
+
if [ -f "$package" ]; then
|
|
40
|
+
if grep -Eq '"name"[[:space:]]*:[[:space:]]*"townmouse"' "$package"; then return 0; fi
|
|
41
|
+
return 1
|
|
42
|
+
fi
|
|
43
|
+
if printf '%s\n' "$server" | grep -Eiq '(^|/)townmouse/src/server\.js$'; then return 0; fi
|
|
44
|
+
return 2
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if [ -f "$LEGACY_PLIST" ]; then
|
|
48
|
+
verdict=0
|
|
49
|
+
is_townmouse_plist || verdict=$?
|
|
50
|
+
case "$verdict" in
|
|
51
|
+
0)
|
|
52
|
+
launchctl bootout "$DOMAIN/$LEGACY_LABEL" 2>/dev/null || true
|
|
53
|
+
rm -f "$LEGACY_PLIST"
|
|
54
|
+
echo " legacy: removed the Townmouse service that 0.2.x installed as $LEGACY_LABEL."
|
|
55
|
+
echo " legacy: TerminalOne's own service, if you use it, comes back by running its scripts/install-service.sh."
|
|
56
|
+
;;
|
|
57
|
+
2)
|
|
58
|
+
echo " legacy: a launch agent named $LEGACY_LABEL exists and could not be told from Townmouse's, so it was left alone."
|
|
59
|
+
echo " legacy: if it runs Townmouse 0.2.x, stop it by hand: launchctl bootout $DOMAIN/$LEGACY_LABEL"
|
|
60
|
+
;;
|
|
61
|
+
esac
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
if [ -n "${TERMINALONE_BIN_DIR:-}" ]; then
|
|
65
|
+
LAUNCHER_DIRS=("$TERMINALONE_BIN_DIR")
|
|
66
|
+
else
|
|
67
|
+
LAUNCHER_DIRS=(/usr/local/bin "$HOME/.local/bin" "$HOME/bin")
|
|
68
|
+
fi
|
|
69
|
+
for dir in "${LAUNCHER_DIRS[@]}"; do
|
|
70
|
+
[ -n "$dir" ] || continue
|
|
71
|
+
stub="$dir/t1"
|
|
72
|
+
if [ -f "$stub" ] && [ ! -L "$stub" ] && grep -qF "$LEGACY_STUB_MARKER" "$stub" 2>/dev/null; then
|
|
73
|
+
rm -f "$stub"
|
|
74
|
+
echo " legacy: removed $stub, the t1 launcher that 0.2.x wrote for Townmouse."
|
|
75
|
+
fi
|
|
76
|
+
done
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Run ordered Terminal Workspace lifecycle hooks with bounded execution."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import subprocess
|
|
9
|
+
import sys
|
|
10
|
+
from datetime import datetime, timezone
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def main() -> int:
|
|
15
|
+
if len(sys.argv) < 2:
|
|
16
|
+
print(f"usage: {sys.argv[0]} EVENT [--best-effort]", file=sys.stderr)
|
|
17
|
+
return 64
|
|
18
|
+
event = sys.argv[1]
|
|
19
|
+
if not event.replace("-", "").replace("_", "").isalnum():
|
|
20
|
+
print(f"invalid hook event: {event}", file=sys.stderr)
|
|
21
|
+
return 64
|
|
22
|
+
best_effort = "--best-effort" in sys.argv[2:]
|
|
23
|
+
root = Path(__file__).resolve().parent.parent
|
|
24
|
+
product = "terminalone"
|
|
25
|
+
timeout = float(os.environ.get("TERMINAL_HOOK_TIMEOUT", "30"))
|
|
26
|
+
hook_roots = [
|
|
27
|
+
root / ".terminal-hooks" / f"{event}.d",
|
|
28
|
+
Path.home() / ".config" / "terminal-workspace" / "hooks" / product / f"{event}.d",
|
|
29
|
+
]
|
|
30
|
+
context = json.dumps({
|
|
31
|
+
"schemaVersion": 1,
|
|
32
|
+
"product": product,
|
|
33
|
+
"event": event,
|
|
34
|
+
"root": str(root),
|
|
35
|
+
"pid": os.getpid(),
|
|
36
|
+
"timestamp": datetime.now(timezone.utc).isoformat(),
|
|
37
|
+
}) + "\n"
|
|
38
|
+
env = os.environ | {
|
|
39
|
+
"TERMINAL_HOOK_EVENT": event,
|
|
40
|
+
"TERMINAL_PRODUCT": product,
|
|
41
|
+
"TERMINAL_PRODUCT_ROOT": str(root),
|
|
42
|
+
}
|
|
43
|
+
failures = 0
|
|
44
|
+
for directory in hook_roots:
|
|
45
|
+
if not directory.is_dir():
|
|
46
|
+
continue
|
|
47
|
+
for hook in sorted(directory.iterdir()):
|
|
48
|
+
if hook.name.startswith(".") or not hook.is_file():
|
|
49
|
+
continue
|
|
50
|
+
if not os.access(hook, os.X_OK):
|
|
51
|
+
print(f"hook skipped (not executable): {hook}", file=sys.stderr)
|
|
52
|
+
continue
|
|
53
|
+
try:
|
|
54
|
+
result = subprocess.run(
|
|
55
|
+
[str(hook)], input=context, text=True, env=env, timeout=timeout, check=False
|
|
56
|
+
)
|
|
57
|
+
if result.returncode:
|
|
58
|
+
failures += 1
|
|
59
|
+
print(f"hook failed ({result.returncode}): {hook}", file=sys.stderr)
|
|
60
|
+
except subprocess.TimeoutExpired:
|
|
61
|
+
failures += 1
|
|
62
|
+
print(f"hook timed out after {timeout:g}s: {hook}", file=sys.stderr)
|
|
63
|
+
if failures and not best_effort:
|
|
64
|
+
return 70
|
|
65
|
+
return 0 if not failures or best_effort else 70
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
if __name__ == "__main__":
|
|
69
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# townmouse — open Townmouse. Ensures the always-on service is running, waits for
|
|
4
|
+
# it to be healthy, then opens the UI as a chrome-less app window (falls back to
|
|
5
|
+
# the default browser). This is the volume-resident implementation; install-service.sh
|
|
6
|
+
# generates a self-contained `townmouse` launcher on the internal disk that delegates
|
|
7
|
+
# here, plus /Applications/Townmouse.app. Run install once, then use `townmouse` or
|
|
8
|
+
# Spotlight.
|
|
9
|
+
#
|
|
10
|
+
# Townmouse keeps its own service name and port so it can sit beside TerminalOne,
|
|
11
|
+
# the engine it embeds: Townmouse is `com.floyd.townmouse` on 11002, TerminalOne is
|
|
12
|
+
# `com.floyd.terminalone` on 11001.
|
|
13
|
+
#
|
|
14
|
+
set -euo pipefail
|
|
15
|
+
|
|
16
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
|
17
|
+
PORT="${PORT:-11002}"
|
|
18
|
+
APP_DIR="${TERMINALONE_APP_DIR:-$(cd "$SCRIPT_DIR/.." && pwd -P)}"
|
|
19
|
+
LOG_DIR="${TERMINALONE_LOG_DIR:-$HOME/Library/Logs/Townmouse}"
|
|
20
|
+
LABEL="com.floyd.townmouse"
|
|
21
|
+
DOMAIN="gui/$(id -u)"
|
|
22
|
+
SERVE_ONLY=false
|
|
23
|
+
|
|
24
|
+
show_usage() {
|
|
25
|
+
cat <<'EOF'
|
|
26
|
+
Usage: townmouse [--port <n>] [--no-open]
|
|
27
|
+
|
|
28
|
+
Open Townmouse, or ensure its service is healthy without opening a browser.
|
|
29
|
+
|
|
30
|
+
Options:
|
|
31
|
+
--port <n> Port for the local server (default 11002)
|
|
32
|
+
--no-open Start or verify the service, then exit
|
|
33
|
+
--serve-only Same as --no-open
|
|
34
|
+
-v, --version Show the installed version and exit
|
|
35
|
+
-h, --help Show this help and exit
|
|
36
|
+
EOF
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
show_error() {
|
|
40
|
+
local msg="$1"
|
|
41
|
+
printf 'townmouse: %s\n' "$msg" >&2
|
|
42
|
+
if [ ! -t 2 ] && command -v osascript >/dev/null 2>&1; then
|
|
43
|
+
osascript -e "display dialog \"$msg\" with title \"Townmouse\" buttons {\"OK\"} default button \"OK\" with icon caution" >/dev/null 2>&1 || true
|
|
44
|
+
fi
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
while [ "$#" -gt 0 ]; do
|
|
48
|
+
case "$1" in
|
|
49
|
+
help|-h|--help)
|
|
50
|
+
show_usage
|
|
51
|
+
exit 0
|
|
52
|
+
;;
|
|
53
|
+
-v|--version)
|
|
54
|
+
sed -n 's/^ "version": "\([^"]*\)".*/\1/p' "$APP_DIR/package.json" | head -n 1
|
|
55
|
+
exit 0
|
|
56
|
+
;;
|
|
57
|
+
--serve-only|--no-open)
|
|
58
|
+
SERVE_ONLY=true
|
|
59
|
+
;;
|
|
60
|
+
--port)
|
|
61
|
+
[ "$#" -ge 2 ] || { show_error "--port needs a number"; exit 2; }
|
|
62
|
+
PORT="$2"
|
|
63
|
+
shift
|
|
64
|
+
;;
|
|
65
|
+
--port=*)
|
|
66
|
+
PORT="${1#--port=}"
|
|
67
|
+
;;
|
|
68
|
+
esac
|
|
69
|
+
shift
|
|
70
|
+
done
|
|
71
|
+
|
|
72
|
+
# The same range bin/townmouse accepts. Leading zeros are ignored.
|
|
73
|
+
port_is_valid() {
|
|
74
|
+
local value="$1" digits
|
|
75
|
+
case "$value" in ''|*[!0-9]*) return 1 ;; esac
|
|
76
|
+
digits="$(printf '%s' "$value" | sed 's/^0*//')"
|
|
77
|
+
digits="${digits:-0}"
|
|
78
|
+
[ "${#digits}" -le 5 ] && [ "$digits" -ge 1 ] && [ "$digits" -le 65535 ]
|
|
79
|
+
}
|
|
80
|
+
if ! port_is_valid "$PORT"; then
|
|
81
|
+
show_error "Invalid port. Use a number from 1 to 65535."
|
|
82
|
+
exit 2
|
|
83
|
+
fi
|
|
84
|
+
|
|
85
|
+
URL="${TERMINALONE_URL:-http://localhost:$PORT}"
|
|
86
|
+
HEALTH_URL="${TERMINALONE_HEALTH_URL:-$URL/health}"
|
|
87
|
+
|
|
88
|
+
wait_for_health() {
|
|
89
|
+
local tries="${1:-32}"
|
|
90
|
+
for _ in $(seq 1 "$tries"); do
|
|
91
|
+
if curl -sf "$HEALTH_URL" >/dev/null 2>&1; then
|
|
92
|
+
return 0
|
|
93
|
+
fi
|
|
94
|
+
sleep 0.25
|
|
95
|
+
done
|
|
96
|
+
return 1
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
start_direct_backend() {
|
|
100
|
+
mkdir -p "$LOG_DIR"
|
|
101
|
+
"$APP_DIR/scripts/run-hooks" pre-start
|
|
102
|
+
nohup env PORT="$PORT" "$APP_DIR/scripts/node-runtime.sh" exec "$APP_DIR/src/server.js" >>"$LOG_DIR/local-launch.out.log" 2>>"$LOG_DIR/local-launch.err.log" &
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if ! wait_for_health 1; then
|
|
106
|
+
# Nudge the service (no-op if it isn't installed / already running).
|
|
107
|
+
launchctl kickstart "$DOMAIN/$LABEL" 2>/dev/null || true
|
|
108
|
+
|
|
109
|
+
if ! wait_for_health 16; then
|
|
110
|
+
# lsof's first line is a column header, not a listener. Inspect command
|
|
111
|
+
# names only on real listener rows so a starting Node service is not
|
|
112
|
+
# mistaken for a foreign process.
|
|
113
|
+
if lsof -nP -iTCP:"$PORT" -sTCP:LISTEN 2>/dev/null \
|
|
114
|
+
| awk 'NR > 1 && tolower($1) !~ /node/ { foreign = 1 } END { exit !foreign }'; then
|
|
115
|
+
show_error "Port $PORT is already in use by another process. Free the port or change Townmouse's port."
|
|
116
|
+
exit 1
|
|
117
|
+
fi
|
|
118
|
+
|
|
119
|
+
if ! "$APP_DIR/scripts/node-runtime.sh" doctor >/dev/null 2>&1; then
|
|
120
|
+
show_error "Townmouse runtime is not ready. Run: townmouse repair"
|
|
121
|
+
exit 1
|
|
122
|
+
fi
|
|
123
|
+
|
|
124
|
+
if [ ! -f "$APP_DIR/src/server.js" ]; then
|
|
125
|
+
show_error "Townmouse files are missing at $APP_DIR."
|
|
126
|
+
exit 1
|
|
127
|
+
fi
|
|
128
|
+
|
|
129
|
+
start_direct_backend
|
|
130
|
+
|
|
131
|
+
if ! wait_for_health 32; then
|
|
132
|
+
"$APP_DIR/scripts/run-hooks" start-error --best-effort
|
|
133
|
+
show_error "Townmouse failed to start. Logs: $LOG_DIR/local-launch.err.log"
|
|
134
|
+
exit 1
|
|
135
|
+
fi
|
|
136
|
+
"$APP_DIR/scripts/run-hooks" post-start --best-effort
|
|
137
|
+
fi
|
|
138
|
+
fi
|
|
139
|
+
|
|
140
|
+
if $SERVE_ONLY; then
|
|
141
|
+
echo "Townmouse service ready -> $URL"
|
|
142
|
+
exit 0
|
|
143
|
+
fi
|
|
144
|
+
|
|
145
|
+
if [ -d "/Applications/Google Chrome.app" ]; then
|
|
146
|
+
open -na "Google Chrome" --args --app="$URL"
|
|
147
|
+
elif [ -d "/Applications/Google Chrome Beta.app" ]; then
|
|
148
|
+
open -na "Google Chrome Beta" --args --app="$URL"
|
|
149
|
+
else
|
|
150
|
+
open "$URL"
|
|
151
|
+
fi
|
|
152
|
+
echo "Townmouse -> $URL"
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# Townmouse — remove the always-on LaunchAgent. Full reversal of install-service.sh.
|
|
4
|
+
# Stops the running service and deletes the plist. Does not touch app code or ports
|
|
5
|
+
# beyond releasing 11002 when the process stops. TerminalOne is a separate product:
|
|
6
|
+
# its service, its `t1` launcher and TerminalOne.app are never removed here.
|
|
7
|
+
#
|
|
8
|
+
set -euo pipefail
|
|
9
|
+
|
|
10
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
|
11
|
+
LABEL="com.floyd.townmouse"
|
|
12
|
+
DOMAIN="gui/$(id -u)"
|
|
13
|
+
PLIST_DIR="${TERMINALONE_PLIST_DIR:-$HOME/Library/LaunchAgents}"
|
|
14
|
+
PLIST="$PLIST_DIR/$LABEL.plist"
|
|
15
|
+
|
|
16
|
+
launchctl bootout "$DOMAIN/$LABEL" 2>/dev/null || true
|
|
17
|
+
if [ -f "$PLIST" ]; then
|
|
18
|
+
rm -f "$PLIST"
|
|
19
|
+
echo "Removed $PLIST"
|
|
20
|
+
else
|
|
21
|
+
echo "No plist found at $PLIST (nothing to remove)"
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
bash "$SCRIPT_DIR/retire-legacy-service.sh"
|
|
25
|
+
|
|
26
|
+
if [ -n "${TERMINALONE_BIN_DIR:-}" ]; then
|
|
27
|
+
LAUNCHER_DIRS=("$TERMINALONE_BIN_DIR")
|
|
28
|
+
else
|
|
29
|
+
LAUNCHER_DIRS=(/usr/local/bin "$HOME/.local/bin" "$HOME/bin")
|
|
30
|
+
fi
|
|
31
|
+
# Remove only the `townmouse` launcher this installer wrote: a regular file
|
|
32
|
+
# whose text says so. A symlink of that name is npm's own command for the
|
|
33
|
+
# package, or someone else's; it is never removed here.
|
|
34
|
+
for dir in "${LAUNCHER_DIRS[@]}"; do
|
|
35
|
+
[ -n "$dir" ] || continue
|
|
36
|
+
launcher="$dir/townmouse"
|
|
37
|
+
if [ -f "$launcher" ] && [ ! -L "$launcher" ] && grep -q 'Townmouse launcher' "$launcher" 2>/dev/null; then
|
|
38
|
+
rm -f "$launcher" && echo "Removed $launcher"
|
|
39
|
+
fi
|
|
40
|
+
done
|
|
41
|
+
|
|
42
|
+
if [ -n "${TERMINALONE_APPLICATIONS_DIR:-}" ]; then
|
|
43
|
+
APP_DIRS=("$TERMINALONE_APPLICATIONS_DIR")
|
|
44
|
+
else
|
|
45
|
+
APP_DIRS=(/Applications "$HOME/Applications")
|
|
46
|
+
fi
|
|
47
|
+
# Remove the no-terminal app launcher Townmouse's installer built, and nothing else.
|
|
48
|
+
for dir in "${APP_DIRS[@]}"; do
|
|
49
|
+
[ -n "$dir" ] || continue
|
|
50
|
+
bundle="$dir/Townmouse.app"
|
|
51
|
+
if [ -d "$bundle" ]; then rm -rf "$bundle" && echo "Removed $bundle"; fi
|
|
52
|
+
done
|
|
53
|
+
|
|
54
|
+
# Remove the PATH line added to shell rc files by install-service.sh.
|
|
55
|
+
# Use ';' not '&&' for mv: grep -vF exits 1 when the marked line is the last
|
|
56
|
+
# remaining content (no output lines), but we must still write the (empty) result.
|
|
57
|
+
MARK="# added by Townmouse install-service.sh"
|
|
58
|
+
for rc in "$HOME/.zshrc" "$HOME/.bash_profile"; do
|
|
59
|
+
if [ -f "$rc" ] && grep -qF "$MARK" "$rc" 2>/dev/null; then
|
|
60
|
+
tmp="$(mktemp)"
|
|
61
|
+
grep -vF "$MARK" "$rc" > "$tmp"; mv "$tmp" "$rc" && echo "Cleaned PATH line from $rc"
|
|
62
|
+
fi
|
|
63
|
+
done
|
|
64
|
+
|
|
65
|
+
echo "Townmouse service uninstalled."
|