# Copyright 2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Autogenerated by pycargoebuild 0.13.2

EAPI=8

CRATES="
	addr2line@0.21.0
	adler@1.0.2
	aes@0.8.4
	ahash@0.7.8
	ahash@0.8.11
	aho-corasick@1.1.3
	ansi_term@0.12.1
	anyhow@1.0.82
	arrayvec@0.7.4
	ashpd@0.8.1
	assert_float_eq@1.1.3
	async-broadcast@0.7.0
	async-channel@2.2.1
	async-executor@1.11.0
	async-fs@2.1.2
	async-io@2.3.2
	async-lock@3.3.0
	async-net@2.0.0
	async-process@2.2.2
	async-recursion@1.1.1
	async-signal@0.2.6
	async-task@4.7.1
	async-trait@0.1.80
	atk-sys@0.18.0
	atk@0.18.0
	atomic-waker@1.1.2
	atty@0.2.14
	autocfg@1.2.0
	backtrace@0.3.71
	base64@0.22.0
	base64ct@1.6.0
	bitflags@1.3.2
	bitflags@2.5.0
	bitvec@1.0.1
	block-buffer@0.10.4
	block-padding@0.3.3
	block@0.1.6
	blocking@1.6.0
	borsh-derive@1.4.0
	borsh@1.4.0
	bumpalo@3.16.0
	bytecheck@0.6.12
	bytecheck_derive@0.6.12
	byteorder@1.5.0
	bytes@1.6.0
	cairo-rs@0.18.5
	cairo-rs@0.19.4
	cairo-sys-rs@0.18.2
	cairo-sys-rs@0.19.2
	cbc@0.1.2
	cc@1.0.95
	cfg-expr@0.15.8
	cfg-if@1.0.0
	cfg_aliases@0.1.1
	cipher@0.4.4
	clap@2.34.0
	cocoa-foundation@0.1.2
	cocoa@0.25.0
	concurrent-queue@2.5.0
	const-oid@0.9.6
	cookie@0.17.0
	cookie@0.18.1
	cookie_store@0.20.0
	core-foundation-sys@0.8.6
	core-foundation@0.9.4
	core-graphics-types@0.1.3
	core-graphics@0.23.2
	cpufeatures@0.2.12
	crc32fast@1.4.0
	crossbeam-channel@0.5.12
	crossbeam-utils@0.8.19
	crypto-common@0.1.6
	darling@0.14.4
	darling_core@0.14.4
	darling_macro@0.14.4
	dbus-codegen@0.9.1
	dbus-tree@0.9.2
	dbus@0.9.7
	der@0.7.9
	deranged@0.3.11
	derivative@2.2.0
	derive_is_enum_variant@0.1.1
	digest@0.10.7
	directories@5.0.1
	dirs-next@2.0.0
	dirs-sys-next@0.1.2
	dirs-sys@0.4.1
	dispatch@0.2.0
	documented-derive@0.4.1
	documented@0.4.1
	dpi@0.1.1
	ecb@0.1.2
	embed-resource@2.4.2
	encoding_rs@0.8.34
	endi@1.1.0
	enum-kinds@0.5.1
	enumflags2@0.7.9
	enumflags2_derive@0.7.9
	equivalent@1.0.1
	errno@0.3.8
	event-listener-strategy@0.4.0
	event-listener-strategy@0.5.2
	event-listener@4.0.3
	event-listener@5.3.0
	fastrand@2.1.0
	fdeflate@0.3.4
	field-offset@0.3.6
	flate2@1.0.30
	fnv@1.0.7
	foreign-types-macros@0.2.3
	foreign-types-shared@0.1.1
	foreign-types-shared@0.3.1
	foreign-types@0.3.2
	foreign-types@0.5.0
	form_urlencoded@1.2.1
	from_variants@1.0.2
	from_variants_impl@1.0.2
	funty@2.0.0
	futures-channel@0.3.30
	futures-core@0.3.30
	futures-executor@0.3.30
	futures-io@0.3.30
	futures-lite@2.3.0
	futures-macro@0.3.30
	futures-sink@0.3.30
	futures-task@0.3.30
	futures-util@0.3.30
	gdk-pixbuf-sys@0.18.0
	gdk-pixbuf-sys@0.19.5
	gdk-pixbuf@0.18.5
	gdk-pixbuf@0.19.2
	gdk-sys@0.18.0
	gdk4-sys@0.8.2
	gdk4-win32-sys@0.8.2
	gdk4-win32@0.8.2
	gdk4@0.8.2
	gdk@0.18.0
	generic-array@0.14.7
	getrandom@0.2.14
	gettext-rs@0.7.0
	gettext-sys@0.21.3
	gimli@0.28.1
	gio-sys@0.18.1
	gio-sys@0.19.5
	gio@0.18.4
	gio@0.19.5
	glib-macros@0.18.5
	glib-macros@0.19.5
	glib-sys@0.18.1
	glib-sys@0.19.5
	glib@0.18.5
	glib@0.19.5
	gobject-sys@0.18.0
	gobject-sys@0.19.5
	graphene-rs@0.19.2
	graphene-sys@0.19.5
	gsk4-sys@0.8.2
	gsk4@0.8.2
	gtk-sys@0.18.0
	gtk3-macros@0.18.0
	gtk4-macros@0.8.2
	gtk4-sys@0.8.2
	gtk4@0.8.2
	gtk@0.18.1
	h2@0.4.4
	hashbrown@0.12.3
	hashbrown@0.14.5
	heck@0.3.3
	heck@0.4.1
	heck@0.5.0
	hermit-abi@0.1.19
	hermit-abi@0.3.9
	hex@0.4.3
	http-body-util@0.1.1
	http-body@1.0.0
	http@1.1.0
	httparse@1.8.0
	hyper-tls@0.6.0
	hyper-util@0.1.3
	hyper@1.3.1
	ident_case@1.0.1
	idna@0.3.0
	idna@0.5.0
	indexmap@2.2.6
	inout@0.1.3
	ipnet@2.9.0
	itoa@1.0.11
	js-sys@0.3.69
	keyboard-types@0.7.0
	ksni@0.2.2
	lazy_static@1.4.0
	libappindicator-sys@0.9.0
	libappindicator@0.9.0
	libc@0.2.153
	libdbus-sys@0.2.5
	libloading@0.7.4
	libm@0.2.8
	libmimalloc-sys@0.1.37
	libredox@0.1.3
	libxdo-sys@0.11.0
	libxdo@0.6.0
	linux-raw-sys@0.4.13
	locale_config@0.3.0
	lock_api@0.4.12
	log@0.4.21
	lrc-nom@0.3.0
	malloc_buf@0.0.6
	matchers@0.1.0
	md5@0.7.0
	memchr@2.7.2
	memoffset@0.9.1
	mimalloc@0.1.41
	mime@0.3.17
	minimal-lexical@0.2.1
	miniz_oxide@0.7.2
	mio@0.8.11
	mpris@2.0.1
	muda@0.13.1
	native-tls@0.2.11
	ncmapi2@0.1.13
	nix@0.28.0
	nom@7.1.3
	nu-ansi-term@0.46.0
	num-bigint-dig@0.8.4
	num-conv@0.1.0
	num-integer@0.1.46
	num-iter@0.1.44
	num-traits@0.2.18
	num_cpus@1.16.0
	objc-foundation@0.1.1
	objc@0.2.7
	objc_id@0.1.1
	object@0.32.2
	once_cell@1.19.0
	opencc-rust@1.1.18
	openssl-macros@0.1.1
	openssl-probe@0.1.5
	openssl-sys@0.9.102
	openssl@0.10.64
	option-ext@0.2.0
	ordered-stream@0.2.0
	overload@0.1.1
	pango-sys@0.18.0
	pango-sys@0.19.5
	pango@0.18.3
	pango@0.19.5
	parking@2.2.0
	parking_lot@0.12.2
	parking_lot_core@0.9.10
	pem-rfc7468@0.7.0
	percent-encoding@2.3.1
	phf@0.11.2
	phf_generator@0.11.2
	phf_macros@0.11.2
	phf_shared@0.11.2
	pin-project-internal@1.1.5
	pin-project-lite@0.2.14
	pin-project@1.1.5
	pin-utils@0.1.0
	piper@0.2.1
	pkcs1@0.7.5
	pkcs8@0.10.2
	pkg-config@0.3.30
	png@0.17.13
	polling@3.7.0
	pollster@0.3.0
	powerfmt@0.2.0
	ppv-lite86@0.2.17
	proc-macro-crate@1.3.1
	proc-macro-crate@2.0.0
	proc-macro-crate@3.1.0
	proc-macro-error-attr@1.0.4
	proc-macro-error@1.0.4
	proc-macro2@1.0.81
	psl-types@2.0.11
	ptr_meta@0.1.4
	ptr_meta_derive@0.1.4
	publicsuffix@2.2.3
	qqmusic-rs@0.1.0
	quote@0.3.15
	quote@1.0.36
	radium@0.7.0
	rand@0.8.5
	rand_chacha@0.3.1
	rand_core@0.6.4
	raw-window-handle@0.6.1
	redox_syscall@0.5.1
	redox_users@0.4.5
	regex-automata@0.1.10
	regex-automata@0.4.6
	regex-syntax@0.6.29
	regex-syntax@0.8.3
	regex@1.10.4
	rend@0.4.2
	reqwest@0.12.4
	rfd@0.14.1
	rkyv@0.7.44
	rkyv_derive@0.7.44
	rsa@0.9.6
	rust_decimal@1.35.0
	rust_decimal_macros@1.34.2
	rustc-demangle@0.1.23
	rustc_version@0.4.0
	rustix@0.38.34
	rustls-pemfile@2.1.2
	rustls-pki-types@1.5.0
	rustversion@1.0.15
	ryu@1.0.17
	schannel@0.1.23
	scopeguard@1.2.0
	seahash@4.1.0
	security-framework-sys@2.10.0
	security-framework@2.10.0
	semver@1.0.22
	serde@1.0.199
	serde_derive@1.0.199
	serde_json@1.0.116
	serde_repr@0.1.19
	serde_spanned@0.6.5
	serde_urlencoded@0.7.1
	sha1@0.10.6
	sharded-slab@0.1.7
	signal-hook-registry@1.4.2
	signature@2.2.0
	simd-adler32@0.3.7
	simdutf8@0.1.4
	siphasher@0.3.11
	slab@0.4.9
	smallvec@1.13.2
	socket2@0.5.7
	sorensen@0.2.0
	spin@0.5.2
	spki@0.7.3
	static_assertions@1.1.0
	strsim@0.10.0
	strsim@0.8.0
	strum@0.26.2
	strum_macros@0.26.2
	subtle@2.5.0
	syn@0.11.11
	syn@1.0.109
	syn@2.0.60
	syn_derive@0.1.8
	sync_wrapper@0.1.2
	synom@0.11.3
	system-configuration-sys@0.5.0
	system-configuration@0.5.1
	system-deps@6.2.2
	tap@1.0.1
	target-lexicon@0.12.14
	temp-dir@0.1.13
	tempfile@3.10.1
	textwrap@0.11.0
	thiserror-impl@1.0.59
	thiserror@1.0.59
	thread_local@1.1.8
	time-core@0.1.2
	time-macros@0.2.18
	time@0.3.36
	tinyvec@1.6.0
	tinyvec_macros@0.1.1
	tokio-macros@2.2.0
	tokio-native-tls@0.3.1
	tokio-util@0.7.10
	tokio@1.37.0
	toml@0.8.12
	toml_datetime@0.6.5
	toml_edit@0.19.15
	toml_edit@0.20.7
	toml_edit@0.21.1
	toml_edit@0.22.12
	tower-layer@0.3.2
	tower-service@0.3.2
	tower@0.4.13
	tracing-attributes@0.1.27
	tracing-core@0.1.32
	tracing-journald@0.3.0
	tracing-log@0.2.0
	tracing-subscriber@0.3.18
	tracing@0.1.40
	tray-icon@0.13.4
	try-lock@0.2.5
	typenum@1.17.0
	uds_windows@1.1.0
	unicode-bidi@0.3.15
	unicode-ident@1.0.12
	unicode-normalization@0.1.23
	unicode-segmentation@1.11.0
	unicode-width@0.1.12
	unicode-xid@0.0.4
	url@2.5.0
	urlencoding@2.1.3
	uuid@1.8.0
	valuable@0.1.0
	vcpkg@0.2.15
	vec_map@0.8.2
	version-compare@0.2.0
	version_check@0.9.4
	vswhom-sys@0.1.2
	vswhom@0.1.0
	want@0.3.1
	wasi@0.11.0+wasi-snapshot-preview1
	wasm-bindgen-backend@0.2.92
	wasm-bindgen-futures@0.4.42
	wasm-bindgen-macro-support@0.2.92
	wasm-bindgen-macro@0.2.92
	wasm-bindgen-shared@0.2.92
	wasm-bindgen@0.2.92
	web-sys@0.3.69
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-x86_64-pc-windows-gnu@0.4.0
	winapi@0.3.9
	windows-core@0.56.0
	windows-implement@0.56.0
	windows-interface@0.56.0
	windows-result@0.1.1
	windows-sys@0.48.0
	windows-sys@0.52.0
	windows-targets@0.48.5
	windows-targets@0.52.5
	windows@0.56.0
	windows_aarch64_gnullvm@0.48.5
	windows_aarch64_gnullvm@0.52.5
	windows_aarch64_msvc@0.48.5
	windows_aarch64_msvc@0.52.5
	windows_exe_info@0.4.2
	windows_i686_gnu@0.48.5
	windows_i686_gnu@0.52.5
	windows_i686_gnullvm@0.52.5
	windows_i686_msvc@0.48.5
	windows_i686_msvc@0.52.5
	windows_x86_64_gnu@0.48.5
	windows_x86_64_gnu@0.52.5
	windows_x86_64_gnullvm@0.48.5
	windows_x86_64_gnullvm@0.52.5
	windows_x86_64_msvc@0.48.5
	windows_x86_64_msvc@0.52.5
	winnow@0.5.40
	winnow@0.6.7
	winreg@0.52.0
	wyz@0.5.1
	x11@2.21.0
	xdg-home@1.1.0
	xml-rs@0.8.20
	zbus@4.1.2
	zbus_macros@4.1.2
	zbus_names@3.0.0
	zerocopy-derive@0.7.32
	zerocopy@0.7.32
	zeroize@1.7.0
	zvariant@4.0.2
	zvariant_derive@4.0.2
	zvariant_utils@1.1.0
"

PLOCALES="en_US zh_CN"
inherit cargo desktop gnome2-utils plocale xdg

DESCRIPTION="Simple On Screen lyrics Display for linux/unix"
HOMEPAGE="
	https://waylyrics.github.io/waylyrics/waylyrics
	https://github.com/waylyrics/waylyrics
"

if [[ "${PV}" == *9999* ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/waylyrics/waylyrics.git"
else
	SRC_URI="
		https://github.com/waylyrics/waylyrics/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
		${CARGO_CRATE_URIS}
	"
	KEYWORDS="~amd64 ~loong"
fi

LICENSE="MIT"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD GPL-3+ ISC MIT
	MPL-2.0 Unicode-DFS-2016 Unlicense
"
SLOT="0"

DEPEND="
	dev-libs/glib:2
	gui-libs/gtk:4
	dev-libs/openssl:=
	sys-apps/dbus
	sys-devel/gettext
	x11-libs/cairo
"
RDEPEND="${DEPEND}"
BDEPEND="
	app-misc/jq
	dev-libs/mimalloc
	>=virtual/rust-1.73:*
"

src_compile() {
	export WAYLYRICS_THEME_PRESETS_DIR="/usr/share/${PN}/themes"
	cargo_src_compile --all-targets --all-features
}

src_install() {
	cargo_src_install

	doicon -s scalable "${S}/res/icons/hicolor/scalable/apps/io.github.waylyrics.Waylyrics.svg"
	domenu "${S}/metainfo/io.github.waylyrics.Waylyrics.desktop"

	insinto "/usr/share/glib-2.0/schemas"
	doins "metainfo/io.github.waylyrics.Waylyrics.gschema.xml"

	insinto "/usr/share/${PN}"
	doins -r themes

	cd "${S}/locales" || die
	install_locale() {
		if [[ -f ${1}/LC_MESSAGES/waylyrics.po ]]; then
			local file=${1}/LC_MESSAGES/waylyrics.po
			msgfmt "${file}" -o "${file%.po}.mo" || die
			insinto /usr/share/locale/${1}/LC_MESSAGES
			doins "${file%.po}.mo"
		fi
	}
	plocale_for_each_locale install_locale
}

pkg_postinst() {
	gnome2_schemas_update
	xdg_pkg_postinst
}

pkg_postrm() {
	gnome2_schemas_update
	xdg_pkg_postrm
}