summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 8c03ffb2a483521508a792f2710132856500e69e (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
# Maintainer: nothing_glows <wppopqpu@outlook.com>

# slightly modified from waylyrics-git

pkgname=waylyrics-layer-shell-git
_pkgname=waylyrics
_appname="io.github.waylyrics.Waylyrics"
pkgver=0.4.6.r3.g9806e9b7
pkgrel=2
pkgdesc="the furry way to show desktop lyrics (git version, with layer-shell feature enabled)"
url="https://github.com/waylyrics/waylyrics"
conflicts=('waylyrics' 'waylyrics-git')
provides=('waylyrics')
arch=('x86_64' 'aarch64')
license=('MIT')
depends=('openssl' 'hicolor-icon-theme' 'gtk4-layer-shell'
    # base
    'dbus' 'gcc-libs' 'glibc'
    # gtk4
    'glib2' 'cairo' 'dconf' 'gtk4'
)
makedepends=('cargo' 'git' 'gettext')
optdepends=(
    'breeze-icons: better tray-icon icons'
    'xdg-desktop-portal: file dialog to import LRC'
)

source=("git+${url}.git")

sha256sums=('SKIP')

options=('!lto')

prepare() {
    cd "${_pkgname}"

	export RUSTUP_TOOLCHAIN=stable
    cargo fetch --locked --target ${CARCH}-unknown-linux-gnu
}

pkgver() {
	cd "${_pkgname}"
	git describe --long --tags | sed 's/^v//;s/-/.r/;s/-/./'
}

build() {
    cd "${_pkgname}"

    export CARGO_TARGET_DIR=target

    # template files
    export WAYLYRICS_THEME_PRESETS_DIR="/usr/share/${_pkgname}/themes"

	export RUSTUP_TOOLCHAIN=stable
    cargo build --frozen --release --all-targets --features layer-shell
}


check() {
    cd "${_pkgname}"

    export CARGO_TARGET_DIR=target
    export WAYLYRICS_THEME_PRESETS_DIR="/usr/share/${_pkgname}/themes"

	export RUSTUP_TOOLCHAIN=stable
    cargo test --frozen --release --features layer-shell
}

package() {
    cd "${_pkgname}"

    install -vDm644 metainfo/"${_appname}.desktop" -t "${pkgdir}/usr/share/applications/"
    # Since waylyrics 0.4.6.r3.g9806e9b7 (upstream commit 75fc74af),
    # gtk4-layer-shell is linked through DT_NEEDED and no longer needs LD_PRELOAD.
    # sed -i 's|^Exec=|Exec=env LD_PRELOAD=/usr/lib/libgtk4-layer-shell.so |' "${pkgdir}/usr/share/applications/${_appname}.desktop"

    install -vDm755 "target/release/${_pkgname}" -t "${pkgdir}/usr/bin/"
    install -vDm644 metainfo/"${_appname}.gschema.xml" -t "${pkgdir}/usr/share/glib-2.0/schemas/"

    install -vdm755 "${pkgdir}/usr/share/${_pkgname}/themes"
    cp -arv themes/* "${pkgdir}/usr/share/${_pkgname}/themes/"
    cp -arv res/icons "${pkgdir}/usr/share/icons"

    # Locale files
    (
        cd locales
        for po in $(find . -type f -name '*.po')
        do
            # Extract locale name (e.g., zh_CN from ./zh_CN/LC_MESSAGES/waylyrics.po)
            locale=$(echo "$po" | sed 's|^\./||' | cut -d'/' -f1)
            mkdir -p "${pkgdir}/usr/share/locale/${locale}/LC_MESSAGES"
            msgfmt -o "${pkgdir}/usr/share/locale/${locale}/LC_MESSAGES/waylyrics.mo" "$po"
        done
    )

    # License
    install -vDm644 "LICENSE" -t "${pkgdir}/usr/share/licenses/${pkgname}/"
}