summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7c728f3eded9857648bb5fe2bc38f0e1e4bce482 (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Maintainer: Insidious Fiddler <aur[at]codycody31[dot]dev>
pkgname=1code
pkgver=0.0.84
pkgrel=1
pkgdesc="Best UI for Claude Code with local and remote agent execution"
arch=('x86_64')
url="https://github.com/21st-dev/1code"
license=('Apache-2.0')
depends=('gtk3' 'nss' 'libxss' 'alsa-lib')
makedepends=('bun' 'python' 'nodejs')
conflicts=("$pkgname-bin" "$pkgname-git")
options=('!strip')
source=("$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz"
        "$pkgname.desktop")
sha256sums=('5d171c657c6c99f96dbb24df04c5125dec5f80d564a3acb112ce5104413b9c7e'
            '44ecea6b700e7f097b4c22669d24ee19ae3d6b61967621eb0dd2eb478eaf47df')

# ci/cd flag: gh repo for auto updates
_ghrepo="21st-dev/1code"

prepare() {
    cd "$srcdir/$pkgname-$pkgver"
    bun install
    bun run claude:download
    bun run codex:download
}

build() {
    cd "$srcdir/$pkgname-$pkgver"
    bun run build
    # Build unpacked directory only (avoids deb/AppImage homepage requirement)
    ./node_modules/.bin/electron-builder --linux dir
}

package() {
    cd "$srcdir/$pkgname-$pkgver"

    # Install the unpacked electron app
    install -dm755 "$pkgdir/opt/$pkgname"
    cp -r release/linux-unpacked/* "$pkgdir/opt/$pkgname/"

    # Create launcher script
    install -dm755 "$pkgdir/usr/bin"
    cat > "$pkgdir/usr/bin/$pkgname" << 'EOF'
#!/bin/bash
exec /opt/1code/21st-desktop "$@"
EOF
    chmod 755 "$pkgdir/usr/bin/$pkgname"

    # Install desktop file
    install -Dm644 "$srcdir/$pkgname.desktop" "$pkgdir/usr/share/applications/$pkgname.desktop"

    # Install icon
    for size in 16 32 48 64 128 256 512; do
        if [[ -f "build/icons/${size}x${size}.png" ]]; then
            install -Dm644 "build/icons/${size}x${size}.png" \
                "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/$pkgname.png"
        fi
    done

    # Fallback icon locations
    if [[ -f "resources/icon.png" ]]; then
        install -Dm644 "resources/icon.png" "$pkgdir/usr/share/pixmaps/$pkgname.png"
    elif [[ -f "build/icon.png" ]]; then
        install -Dm644 "build/icon.png" "$pkgdir/usr/share/pixmaps/$pkgname.png"
    fi

    # Install license
    install -Dm644 "LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}