Repository navigation
Expand file tree
/
Copy pathstartt3code
More file actions
executable file
·55 lines (45 loc) · 2.19 KB
/
Copy pathstartt3code
File metadata and controls
executable file
·55 lines (45 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
export TMPDIR="$XDG_RUNTIME_DIR/app/${FLATPAK_ID:-com.t3tools.t3code}"
export NPM_CONFIG_PREFIX="${XDG_DATA_HOME:-$HOME/.local/share}/npm-global"
export NPM_CONFIG_CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/npm"
# Flatpak mounts optional tool extensions but does not add their commands to
# PATH. Keep npm and bundled commands ahead of extension commands.
tools_path=""
for tool_bin in /app/tools/*/bin; do
[[ -d "$tool_bin" ]] && tools_path+=":$tool_bin"
done
export PATH="$NPM_CONFIG_PREFIX/bin:/app/bin$tools_path:$PATH"
unset tools_path tool_bin
mkdir -p "$NPM_CONFIG_PREFIX" "$NPM_CONFIG_CACHE"
# Anything written to $HOME outside ~/.var/app/$FLATPAK_ID and the --persist
# dirs in the manifest is lost when the sandbox exits. Steer remaining
# home-relative state into persistent locations. Host credentials and tools
# are not exposed by the manifest.
# Claude Code keeps ~/.claude.json next to (not inside) ~/.claude unless
# CLAUDE_CONFIG_DIR is set. Point it at the persisted ~/.claude so the file
# lands there too.
export CLAUDE_CONFIG_DIR="${CLAUDE_CONFIG_DIR:-$HOME/.claude}"
# `git config --global` writes to $XDG_CONFIG_HOME/git/config instead of
# ~/.gitconfig when the former exists and the latter does not.
git_xdg_config="${XDG_CONFIG_HOME:-$HOME/.config}/git/config"
mkdir -p "$(dirname -- "$git_xdg_config")"
[[ -e "$git_xdg_config" ]] || : > "$git_xdg_config"
# Older Flatpak clients do not set XDG_STATE_HOME. Keep their shell history
# under app-private persistent storage too, rather than the temporary home.
export HISTFILE="${HISTFILE:-${XDG_STATE_HOME:-$HOME/.var/app/${FLATPAK_ID:-com.t3tools.t3code}/.local/state}/bash/history}"
mkdir -p "$(dirname -- "$HISTFILE")"
declare -a FLAGS=()
if [[ -n "$WAYLAND_DISPLAY" ]]; then
if [[ -c /dev/nvidia0 ]]; then
echo "Using NVIDIA on Wayland, disabling gpu sandbox"
FLAGS+=(--disable-gpu-sandbox)
fi
echo "Running on native Wayland"
FLAGS+=(--ozone-platform-hint=auto)
FLAGS+=(--enable-wayland-ime)
FLAGS+=(--wayland-text-input-version=3)
else
echo "Running on X11"
fi
echo "Passing the following arguments to Electron:" "${FLAGS[@]}" "$@"
zypak-wrapper /app/bin/t3code/t3code "${FLAGS[@]}" "$@"