summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 451e893170b9a6eb6d2433772c0455cb48d5c615 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# Maintainer: shrimp
# Akiflow Desktop for Linux (unofficial)

pkgname=akiflow-bin
pkgver=2.72.5
pkgrel=1
_buildhash=7536ef84
pkgdesc="Akiflow - Time blocking and task management (unofficial Linux build)"
arch=('x86_64')
url="https://akiflow.com"
license=('custom')
depends=('electron')
makedepends=('p7zip' 'imagemagick' 'icoutils' 'python')
_ghraw="https://raw.githubusercontent.com/shrimpwtf/akiflow-arch/main"
source=("Akiflow-${pkgver}.exe::https://download.akiflow.com/builds/Akiflow-${pkgver}-${_buildhash}-x64.exe"
        "patch-main.py::${_ghraw}/patch-main.py"
        "plasma-widget-metadata.json::${_ghraw}/plasma-widget/package/metadata.json"
        "plasma-widget-main.qml::${_ghraw}/plasma-widget/package/contents/ui/main.qml"
        "plasma-widget-CompactRepresentation.qml::${_ghraw}/plasma-widget/package/contents/ui/CompactRepresentation.qml"
        "plasma-widget-FullRepresentation.qml::${_ghraw}/plasma-widget/package/contents/ui/FullRepresentation.qml"
        "plasma-widget-akiflow.png::${_ghraw}/plasma-widget/package/contents/icons/akiflow.png")
sha512sums=('e4aeadcf7ec8a2a9c46dda84fe59d1cf38898808f891d28f98c73c8e1514d61051f4fa19215774c56c5c297befddefce4f8e55a6ec9bc92ed5d6a8b59c5a155d'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP')

prepare() {
    cd "${srcdir}"

    # Extract the NSIS installer
    7z x -y "Akiflow-${pkgver}.exe" -oextracted

    # Extract icons from exe if present
    if [ -f "extracted/\$PLUGINSDIR/app-64.7z" ]; then
        7z x -y "extracted/\$PLUGINSDIR/app-64.7z" -oapp
    else
        # Fallback: the app might be directly in extracted
        cp -r extracted app 2>/dev/null || true
    fi

    # Try to extract icon
    if [ -f "app/Akiflow.exe" ]; then
        wrestool -x -t 14 app/Akiflow.exe -o akiflow.ico 2>/dev/null || true
    elif [ -f "extracted/Akiflow.exe" ]; then
        wrestool -x -t 14 extracted/Akiflow.exe -o akiflow.ico 2>/dev/null || true
    fi

    # Convert ico to png if we got one
    if [ -f "akiflow.ico" ]; then
        icotool -x akiflow.ico 2>/dev/null || true
        mkdir -p icons/hicolor
        for size in 16 24 32 48 64 128 256; do
            icon_file=$(ls akiflow_*"${size}x${size}"*.png 2>/dev/null | head -1)
            if [ -n "$icon_file" ]; then
                mkdir -p "icons/hicolor/${size}x${size}/apps"
                cp "$icon_file" "icons/hicolor/${size}x${size}/apps/akiflow.png"
            fi
        done
    fi
}

_find_asar() {
    if [ -f "${srcdir}/app/resources/app.asar" ]; then
        echo "${srcdir}/app/resources"
    elif [ -f "${srcdir}/extracted/resources/app.asar" ]; then
        echo "${srcdir}/extracted/resources"
    else
        dirname "$(find "${srcdir}" -name 'app.asar' -type f | head -1)"
    fi
}

build() {
    # Patch app.asar to write tray status for the KDE Plasma widget
    ASAR_PATH="$(_find_asar)"
    if [ -z "$ASAR_PATH" ] || [ ! -f "$ASAR_PATH/app.asar" ]; then
        echo "ERROR: Could not find app.asar"
        exit 1
    fi

    cd "$ASAR_PATH"
    python "${srcdir}/patch-main.py"
}

package() {
    ASAR_PATH="$(_find_asar)"
    if [ -z "$ASAR_PATH" ] || [ ! -f "$ASAR_PATH/app.asar" ]; then
        echo "ERROR: Could not find app.asar"
        exit 1
    fi

    # Install app files
    install -d "${pkgdir}/usr/lib/${pkgname}"
    cp "$ASAR_PATH/app.asar" "${pkgdir}/usr/lib/${pkgname}/"

    # Copy unpacked resources if they exist
    if [ -d "$ASAR_PATH/app.asar.unpacked" ]; then
        cp -r "$ASAR_PATH/app.asar.unpacked" "${pkgdir}/usr/lib/${pkgname}/"
    fi

    # Install icons if we extracted them
    if [ -d "${srcdir}/icons/hicolor" ]; then
        install -d "${pkgdir}/usr/share/icons"
        cp -r "${srcdir}/icons/"* "${pkgdir}/usr/share/icons/"
    fi

    # Create desktop file
    install -Dm644 /dev/stdin "${pkgdir}/usr/share/applications/${pkgname}.desktop" <<EOF
[Desktop Entry]
Name=Akiflow
GenericName=Task Management
Comment=Time blocking and task management
Exec=${pkgname} %u
Icon=akiflow
Type=Application
Terminal=false
Categories=Office;ProjectManagement;Calendar;
MimeType=x-scheme-handler/akiflow;
StartupWMClass=Akiflow
EOF

    # Create launcher script
    install -Dm755 /dev/stdin "${pkgdir}/usr/bin/${pkgname}" <<EOF
#!/bin/sh
exec electron --class=Akiflow --name=Akiflow /usr/lib/${pkgname}/app.asar "\$@"
EOF

    # Install KDE Plasma widget for upcoming events
    install -d "${pkgdir}/usr/share/plasma/plasmoids/com.akiflow.panelwidget/contents/ui"
    install -d "${pkgdir}/usr/share/plasma/plasmoids/com.akiflow.panelwidget/contents/icons"
    install -Dm644 "${srcdir}/plasma-widget-metadata.json" \
        "${pkgdir}/usr/share/plasma/plasmoids/com.akiflow.panelwidget/metadata.json"
    install -Dm644 "${srcdir}/plasma-widget-main.qml" \
        "${pkgdir}/usr/share/plasma/plasmoids/com.akiflow.panelwidget/contents/ui/main.qml"
    install -Dm644 "${srcdir}/plasma-widget-CompactRepresentation.qml" \
        "${pkgdir}/usr/share/plasma/plasmoids/com.akiflow.panelwidget/contents/ui/CompactRepresentation.qml"
    install -Dm644 "${srcdir}/plasma-widget-FullRepresentation.qml" \
        "${pkgdir}/usr/share/plasma/plasmoids/com.akiflow.panelwidget/contents/ui/FullRepresentation.qml"
    install -Dm644 "${srcdir}/plasma-widget-akiflow.png" \
        "${pkgdir}/usr/share/plasma/plasmoids/com.akiflow.panelwidget/contents/icons/akiflow.png"
}