feat: Claude Desktop personal/work profile launchers, claude:// dispatcher and handlers (Linux only)
This commit is contained in:
1 parent
b4d8701665
commit
9baaf78522
11 files changed
+172
No files matched your search
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/bin/zsh
|
||||
# Claude Desktop — isolated "personal" profile.
|
||||
# --user-data-dir : separate Electron profile; also separates the
|
||||
# single-instance lockfile, which is what allows a
|
||||
# second concurrent instance to run at all.
|
||||
# --password-store : app only auto-detects on KDE; XFCE would fall back
|
||||
# to basic_text, where safeStorage is unavailable and
|
||||
# OAuth tokens do not survive a restart.
|
||||
# --class : distinct WM_CLASS so xfwm/taskbar treats the two
|
||||
# windows as separate apps.
|
||||
export CLAUDE_CONFIG_DIR="${CLAUDE_CONFIG_DIR:-$HOME/.claude}"
|
||||
export PATH="$HOME/.local/share/claude-shims/personal:$PATH"
|
||||
exec /usr/bin/claude-desktop \
|
||||
--user-data-dir="$HOME/.local/share/claude-personal" \
|
||||
--password-store=gnome-libsecret \
|
||||
--class=ClaudePersonal \
|
||||
"$@"
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/bin/zsh
|
||||
# Routes claude:// URLs (OAuth callbacks, deep links) to the correct profile.
|
||||
#
|
||||
# The packaged entry runs plain `claude-desktop %U` with no flags, which
|
||||
# starts an unflagged default-profile instance that has no keyring backend
|
||||
# and cannot save the sign-in. This picks the right profile instead.
|
||||
#
|
||||
# Ordering:
|
||||
# 1. A fresh hint written by that profile's xdg-open shim when the app
|
||||
# opened the browser -- this is the authoritative signal, and it is
|
||||
# consumed on use so it can never misroute a later link.
|
||||
# 2. Whichever profile is the only one running.
|
||||
# 3. The most recently started instance, else personal.
|
||||
#
|
||||
# Handing the URL to the profile wrapper is safe: Electron's second-instance
|
||||
# handler forwards it into the running instance with that --user-data-dir.
|
||||
url="$1"
|
||||
hint="$HOME/.config/claude-profile-target"
|
||||
HINT_MAX_AGE=600 # seconds; ignore an abandoned sign-in attempt
|
||||
running() { pgrep -f -- "--user-data-dir=$HOME/.local/share/claude-$1" >/dev/null 2>&1 }
|
||||
|
||||
target=""
|
||||
if [[ -r "$hint" ]]; then
|
||||
age=$(( $(date +%s) - $(stat -c %Y "$hint") ))
|
||||
if (( age <= HINT_MAX_AGE )); then
|
||||
candidate="$(<"$hint")"
|
||||
[[ "$candidate" == (personal|work) ]] && target="$candidate"
|
||||
fi
|
||||
rm -f "$hint"
|
||||
fi
|
||||
|
||||
if [[ -z "$target" ]]; then
|
||||
if running personal && ! running work; then
|
||||
target=personal
|
||||
elif running work && ! running personal; then
|
||||
target=work
|
||||
else
|
||||
target=$(for p in personal work; do
|
||||
pid=$(pgrep -f -- "--user-data-dir=$HOME/.local/share/claude-$p" | head -1)
|
||||
[[ -n "$pid" ]] && echo "$(ps -o lstart= -p $pid | xargs -I{} date -d {} +%s) $p"
|
||||
done | sort -rn | head -1 | cut -d' ' -f2)
|
||||
target="${target:-personal}"
|
||||
fi
|
||||
fi
|
||||
exec "$HOME/.local/bin/claude-$target" "$url"
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/bin/zsh
|
||||
# Claude Desktop — isolated "work" profile.
|
||||
# --user-data-dir : separate Electron profile; also separates the
|
||||
# single-instance lockfile, which is what allows a
|
||||
# second concurrent instance to run at all.
|
||||
# --password-store : app only auto-detects on KDE; XFCE would fall back
|
||||
# to basic_text, where safeStorage is unavailable and
|
||||
# OAuth tokens do not survive a restart.
|
||||
# --class : distinct WM_CLASS so xfwm/taskbar treats the two
|
||||
# windows as separate apps.
|
||||
export CLAUDE_CONFIG_DIR="${CLAUDE_CONFIG_DIR:-$HOME/.claude-work}"
|
||||
export PATH="$HOME/.local/share/claude-shims/work:$PATH"
|
||||
exec /usr/bin/claude-desktop \
|
||||
--user-data-dir="$HOME/.local/share/claude-work" \
|
||||
--password-store=gnome-libsecret \
|
||||
--class=ClaudeWork \
|
||||
"$@"
|
||||
@@ -0,0 +1,10 @@
|
||||
[Desktop Entry]
|
||||
Name=Claude (Personal)
|
||||
Comment=Claude Desktop — personal account
|
||||
GenericName=AI Assistant
|
||||
Exec={{ .chezmoi.homeDir }}/.local/bin/claude-personal %U
|
||||
Icon=claude-desktop
|
||||
Type=Application
|
||||
StartupNotify=true
|
||||
StartupWMClass=ClaudePersonal
|
||||
Categories=Utility;Development;
|
||||
@@ -0,0 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Name=Claude (profile-aware link handler)
|
||||
Exec={{ .chezmoi.homeDir }}/.local/bin/claude-url-dispatch %u
|
||||
Type=Application
|
||||
NoDisplay=true
|
||||
MimeType=x-scheme-handler/claude;
|
||||
@@ -0,0 +1,10 @@
|
||||
[Desktop Entry]
|
||||
Name=Claude (Work)
|
||||
Comment=Claude Desktop — work account
|
||||
GenericName=AI Assistant
|
||||
Exec={{ .chezmoi.homeDir }}/.local/bin/claude-work %U
|
||||
Icon=claude-desktop
|
||||
Type=Application
|
||||
StartupNotify=true
|
||||
StartupWMClass=ClaudeWork
|
||||
Categories=Utility;Development;
|
||||
@@ -0,0 +1,7 @@
|
||||
[Desktop Entry]
|
||||
Name=Claude Code URL Handler
|
||||
Comment=Handle claude-cli:// deep links for Claude Code
|
||||
Exec="{{ .chezmoi.homeDir }}/.local/bin/claude" --handle-uri %u
|
||||
Type=Application
|
||||
NoDisplay=true
|
||||
MimeType=x-scheme-handler/claude-cli;
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
# PATH shim, injected only into the "personal" Claude instance.
|
||||
# Electron shells out to xdg-open (via PATH) to open the browser for
|
||||
# sign-in. Recording the profile here is what lets the claude:// callback
|
||||
# find its way back to the instance that actually started the login.
|
||||
printf '%s' "personal" > "$HOME/.config/claude-profile-target" 2>/dev/null
|
||||
exec /usr/bin/xdg-open "$@"
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
# PATH shim, injected only into the "work" Claude instance.
|
||||
# Electron shells out to xdg-open (via PATH) to open the browser for
|
||||
# sign-in. Recording the profile here is what lets the claude:// callback
|
||||
# find its way back to the instance that actually started the login.
|
||||
printf '%s' "work" > "$HOME/.config/claude-profile-target" 2>/dev/null
|
||||
exec /usr/bin/xdg-open "$@"
|
||||
Reference in new issue
Block a user