mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-07-10 16:01:00 +02:00
Merge pull request #2826 from alexbelgium/codex/fix-default-settings-for-claude-addon
Fix Claude Desktop optional tool startup
This commit is contained in:
@@ -13,4 +13,9 @@ dbus-update-activation-environment --all >/dev/null 2>&1 || true
|
|||||||
|
|
||||||
# --password-store=gnome-libsecret forces Electron onto the libsecret backend instead of
|
# --password-store=gnome-libsecret forces Electron onto the libsecret backend instead of
|
||||||
# falling back to plaintext (and warning that the sign-in will not be saved).
|
# falling back to plaintext (and warning that the sign-in will not be saved).
|
||||||
claude-desktop --no-sandbox --disable-dev-shm-usage --password-store=gnome-libsecret
|
CLAUDE_DESKTOP_COMMAND_FILE="/tmp/claude-desktop-command"
|
||||||
|
if [ -s "$CLAUDE_DESKTOP_COMMAND_FILE" ]; then
|
||||||
|
sh -c "$(cat "$CLAUDE_DESKTOP_COMMAND_FILE")"
|
||||||
|
else
|
||||||
|
claude-desktop --no-sandbox --disable-dev-shm-usage --password-store=gnome-libsecret
|
||||||
|
fi
|
||||||
|
|||||||
@@ -4,9 +4,14 @@ set -e
|
|||||||
set -o pipefail
|
set -o pipefail
|
||||||
mkdir -p "$HOME/.claude"
|
mkdir -p "$HOME/.claude"
|
||||||
|
|
||||||
|
CLAUDE_DESKTOP_COMMAND_FILE="/tmp/claude-desktop-command"
|
||||||
|
DEFAULT_CLAUDE_DESKTOP_COMMAND='claude-desktop --no-sandbox --disable-dev-shm-usage --password-store=gnome-libsecret'
|
||||||
|
printf '%s\n' "$DEFAULT_CLAUDE_DESKTOP_COMMAND" > "$CLAUDE_DESKTOP_COMMAND_FILE"
|
||||||
|
|
||||||
if bashio::config.true 'install_headroom'; then
|
if bashio::config.true 'install_headroom'; then
|
||||||
if command -v headroom &> /dev/null; then
|
if command -v headroom &> /dev/null; then
|
||||||
bashio::log.info "headroom $(headroom --version 2> /dev/null || true) available. Use 'headroom wrap claude' or MCP mode from Claude Code."
|
bashio::log.info "headroom $(headroom --version 2> /dev/null || true) available; launching Claude Desktop through headroom"
|
||||||
|
printf '%s\n' "headroom wrap $DEFAULT_CLAUDE_DESKTOP_COMMAND" > "$CLAUDE_DESKTOP_COMMAND_FILE"
|
||||||
else
|
else
|
||||||
bashio::log.warning "headroom is not available"
|
bashio::log.warning "headroom is not available"
|
||||||
fi
|
fi
|
||||||
@@ -14,11 +19,31 @@ fi
|
|||||||
|
|
||||||
if bashio::config.true 'install_rtk'; then
|
if bashio::config.true 'install_rtk'; then
|
||||||
if command -v rtk &> /dev/null; then
|
if command -v rtk &> /dev/null; then
|
||||||
if [ -f "$HOME/.claude/settings.json" ] && grep -q 'rtk' "$HOME/.claude/settings.json"; then
|
if [ -f "$HOME/.claude/settings.json" ] && grep -q 'rtk hook claude' "$HOME/.claude/settings.json"; then
|
||||||
bashio::log.info "rtk Claude Code hook already configured"
|
bashio::log.info "rtk Claude Code hook already configured"
|
||||||
else
|
else
|
||||||
bashio::log.info "Configuring rtk Claude Code hook"
|
bashio::log.info "Configuring rtk Claude Code hook"
|
||||||
rtk init -g || bashio::log.warning "rtk hook configuration failed"
|
RTK_NONINTERACTIVE=1 rtk init -g || bashio::log.warning "rtk global files configuration failed"
|
||||||
|
python3 - <<'PY' || bashio::log.warning "Unable to configure rtk hook automatically"
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
path = Path.home() / ".claude" / "settings.json"
|
||||||
|
try:
|
||||||
|
data = json.loads(path.read_text()) if path.exists() else {}
|
||||||
|
if not isinstance(data, dict):
|
||||||
|
data = {}
|
||||||
|
except Exception:
|
||||||
|
if path.exists():
|
||||||
|
path.rename(path.with_suffix(path.suffix + ".bak"))
|
||||||
|
data = {}
|
||||||
|
hooks = data.setdefault("hooks", {})
|
||||||
|
pre = hooks.setdefault("PreToolUse", [])
|
||||||
|
rtk_entry = {"matcher": "Bash", "hooks": [{"type": "command", "command": "rtk hook claude"}]}
|
||||||
|
if not any("rtk hook claude" in json.dumps(entry) for entry in pre if isinstance(entry, dict)):
|
||||||
|
pre.append(rtk_entry)
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
path.write_text(json.dumps(data, indent=2) + "\n")
|
||||||
|
PY
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
bashio::log.warning "rtk is not available"
|
bashio::log.warning "rtk is not available"
|
||||||
|
|||||||
@@ -29,15 +29,13 @@ if bashio::config.has_value 'github_token'; then
|
|||||||
token="$(bashio::config 'github_token')"
|
token="$(bashio::config 'github_token')"
|
||||||
mkdir -p "$HOME/.config/gh"
|
mkdir -p "$HOME/.config/gh"
|
||||||
chmod 700 "$HOME/.config/gh"
|
chmod 700 "$HOME/.config/gh"
|
||||||
export GH_TOKEN="$token"
|
if env -u GH_TOKEN -u GITHUB_TOKEN gh auth status --hostname github.com > /dev/null 2>&1; then
|
||||||
export GITHUB_TOKEN="$token"
|
|
||||||
if gh auth status --hostname github.com > /dev/null 2>&1; then
|
|
||||||
bashio::log.info "GitHub CLI already authenticated for github.com"
|
bashio::log.info "GitHub CLI already authenticated for github.com"
|
||||||
else
|
else
|
||||||
bashio::log.info "Configuring GitHub CLI authentication for github.com"
|
bashio::log.info "Configuring GitHub CLI authentication for github.com"
|
||||||
printf '%s\n' "$token" | gh auth login --hostname github.com --with-token || bashio::log.warning "GitHub CLI authentication failed"
|
printf '%s\n' "$token" | env -u GH_TOKEN -u GITHUB_TOKEN gh auth login --hostname github.com --with-token || bashio::log.warning "GitHub CLI authentication failed"
|
||||||
fi
|
fi
|
||||||
gh auth setup-git --hostname github.com || bashio::log.warning "GitHub CLI git credential setup failed"
|
env -u GH_TOKEN -u GITHUB_TOKEN gh auth setup-git --hostname github.com || bashio::log.warning "GitHub CLI git credential setup failed"
|
||||||
else
|
else
|
||||||
bashio::log.info "GitHub CLI available. Set github_token to authenticate gh and git operations."
|
bashio::log.info "GitHub CLI available. Set github_token to authenticate gh and git operations."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user