1# Maintainer: maria-rcks <maria at kuuro dot net>
2
3pkgname=t3code-bin
4pkgver=0.0.33
5pkgrel=1
6pkgdesc='Desktop control surface for local coding agents'
7arch=('x86_64')
8url='https://github.com/pingdotgg/t3code'
9license=('MIT')
10depends=(
11 'alsa-lib'
12 'at-spi2-core'
13 'cairo'
14 'dbus'
15 'expat'
16 'gdk-pixbuf2'
17 'glib2'
18 'glibc'
19 'gtk3'
20 'hicolor-icon-theme'
21 'libcups'
22 'libdrm'
23 'libgcc'
24 'libstdc++'
25 'libx11'
26 'libxcb'
27 'libxcomposite'
28 'libxdamage'
29 'libxext'
30 'libxfixes'
31 'libxkbcommon'
32 'libxrandr'
33 'mesa'
34 'nspr'
35 'nss'
36 'pango'
37 'systemd-libs'
38 'xdg-utils'
39 'zlib'
40)
41optdepends=('openai-codex: use the system-installed Codex CLI')
42provides=("t3code=$pkgver")
43conflicts=('t3code')
44options=('!debug' '!strip')
45
46_appimage="T3-Code-${pkgver}-x86_64.AppImage"
47source=(
48 "$_appimage::https://github.com/pingdotgg/t3code/releases/download/v${pkgver}/$_appimage"
49 "${pkgname}-${pkgver}-LICENSE::https://raw.githubusercontent.com/pingdotgg/t3code/v${pkgver}/LICENSE"
50)
51sha256sums=(
52 '415c8648f43c3d22d572f27f2c50fdc8c310ea7fcde9537b903e1e2f1c8775a1' # AppImage
53 '935d8f2af0c703f9c39517ee57cc4930b19d02d533be930b63f0e82f93614b43' # upstream license
54)
55
56prepare() {
57 chmod +x "$srcdir/$_appimage"
58 rm -rf "$srcdir/squashfs-root"
59 "$srcdir/$_appimage" --appimage-extract >/dev/null
60
61 if [[ ! -x "$srcdir/squashfs-root/AppRun" ||
62 ! -f "$srcdir/squashfs-root/chrome-sandbox" ]]; then
63 echo 'The AppImage payload is missing its launcher or Chromium sandbox.' >&2
64 return 1
65 fi
66}
67
68package() {
69 install -d "$pkgdir/opt/$pkgname"
70 cp -a --no-preserve=ownership "$srcdir/squashfs-root/." "$pkgdir/opt/$pkgname/"
71 chmod -R u=rwX,go=rX "$pkgdir/opt/$pkgname"
72 chmod 4755 "$pkgdir/opt/$pkgname/chrome-sandbox"
73
74 install -Dm755 /dev/stdin "$pkgdir/usr/bin/t3code" <<'EOF'
75#!/bin/sh
76# AppRun computes APPDIR but doesn't export it. The server's AppImage env scrub needs it
77# to keep /opt/t3code-bin/usr/lib etc. out of terminal and agent shells (#28993).
78exec env APPDIR=/opt/t3code-bin /opt/t3code-bin/AppRun "$@"
79EOF
80 ln -s t3code "$pkgdir/usr/bin/t3-code-desktop"
81
82 # Icon lookup only sees sizes registered in hicolor's index.theme (max 512x512).
83 local icon size_dir
84 for icon in "$srcdir"/squashfs-root/usr/share/icons/hicolor/*/apps/t3code.png; do
85 size_dir="${icon%/apps/t3code.png}"
86 install -Dm644 "$icon" \
87 "$pkgdir/usr/share/icons/hicolor/${size_dir##*/}/apps/t3code.png"
88 done
89
90 install -Dm644 /dev/stdin "$pkgdir/usr/share/applications/t3code.desktop" <<'EOF'
91[Desktop Entry]
92Name=T3 Code
93Comment=Desktop control surface for local coding agents
94Exec=t3code %U
95TryExec=t3code
96Terminal=false
97Type=Application
98Icon=t3code
99StartupWMClass=com.t3tools.T3Code
100Categories=Development;
101MimeType=x-scheme-handler/t3code;
102EOF
103
104 install -Dm644 "$srcdir/${pkgname}-${pkgver}-LICENSE" \
105 "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
106}