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

# Autogenerated by pycargoebuild 0.13.4

EAPI=8

CRATES="
	addr2line@0.24.2
	adler2@2.0.0
	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.93
	arrayvec@0.7.6
	ashpd@0.10.2
	ashpd@0.9.2
	assert_float_eq@1.1.3
	async-broadcast@0.7.1
	async-channel@2.3.1
	async-executor@1.13.1
	async-fs@2.1.2
	async-io@2.4.0
	async-lock@3.4.0
	async-net@2.0.0
	async-process@2.3.0
	async-recursion@1.1.1
	async-signal@0.2.10
	async-task@4.7.1
	async-trait@0.1.83
	atk-sys@0.18.0
	atk@0.18.0
	atomic-waker@1.1.2
	atty@0.2.14
	autocfg@1.4.0
	backtrace@0.3.74
	base64@0.22.1
	base64ct@1.6.0
	bitflags@1.3.2
	bitflags@2.6.0
	bitvec@1.0.1
	block-buffer@0.10.4
	block-padding@0.3.3
	block2@0.5.1
	block@0.1.6
	blocking@1.6.1
	borsh-derive@1.5.2
	borsh@1.5.2
	bumpalo@3.16.0
	bytecheck@0.6.12
	bytecheck_derive@0.6.12
	byteorder@1.5.0
	bytes@1.8.0
	cairo-rs@0.18.5
	cairo-rs@0.20.5
	cairo-sys-rs@0.18.2
	cairo-sys-rs@0.20.0
	cbc@0.1.2
	cc@1.1.37
	cfg-expr@0.15.8
	cfg-expr@0.17.0
	cfg-if@1.0.0
	cfg_aliases@0.2.1
	cipher@0.4.4
	clap@2.34.0
	concurrent-queue@2.5.0
	const-oid@0.9.6
	convert_case@0.6.0
	cookie@0.18.1
	cookie_store@0.21.1
	core-foundation-sys@0.8.7
	core-foundation@0.10.0
	core-foundation@0.9.4
	core-graphics-types@0.2.0
	core-graphics@0.24.0
	cpufeatures@0.2.14
	crc32fast@1.4.2
	crossbeam-channel@0.5.13
	crossbeam-utils@0.8.20
	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
	derive_is_enum_variant@0.1.1
	digest@0.10.7
	directories@5.0.1
	dirs-sys@0.4.1
	dirs@5.0.1
	dispatch@0.2.0
	displaydoc@0.2.5
	dlib@0.5.2
	document-features@0.2.10
	documented-macros@0.9.1
	documented@0.9.1
	downcast-rs@1.2.1
	dpi@0.1.1
	ecb@0.1.2
	either@1.13.0
	embed-resource@2.5.1
	encoding_rs@0.8.35
	endi@1.1.0
	enum-kinds@0.5.1
	enumflags2@0.7.10
	enumflags2_derive@0.7.10
	equivalent@1.0.1
	errno@0.3.9
	event-listener-strategy@0.5.2
	event-listener@5.3.1
	fastrand@2.2.0
	fdeflate@0.3.6
	field-offset@0.3.6
	flate2@1.0.34
	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.31
	futures-core@0.3.31
	futures-executor@0.3.31
	futures-io@0.3.31
	futures-lite@2.5.0
	futures-macro@0.3.31
	futures-sink@0.3.31
	futures-task@0.3.31
	futures-util@0.3.31
	futures@0.3.31
	gdk-pixbuf-sys@0.18.0
	gdk-pixbuf-sys@0.20.4
	gdk-pixbuf@0.18.5
	gdk-pixbuf@0.20.4
	gdk-sys@0.18.0
	gdk4-sys@0.9.3
	gdk4-win32-sys@0.9.3
	gdk4-win32@0.9.3
	gdk4@0.9.3
	gdk@0.18.0
	generic-array@0.14.7
	getrandom@0.2.15
	gettext-rs@0.7.2
	gettext-sys@0.22.5
	gimli@0.31.1
	gio-sys@0.18.1
	gio-sys@0.20.5
	gio@0.18.4
	gio@0.20.5
	glib-macros@0.18.5
	glib-macros@0.20.5
	glib-sys@0.18.1
	glib-sys@0.20.5
	glib@0.18.5
	glib@0.20.5
	gobject-sys@0.18.0
	gobject-sys@0.20.4
	graphene-rs@0.20.4
	graphene-sys@0.20.4
	gsk4-sys@0.9.3
	gsk4@0.9.3
	gtk-sys@0.18.0
	gtk3-macros@0.18.0
	gtk4-macros@0.9.3
	gtk4-sys@0.9.4
	gtk4@0.9.4
	gtk@0.18.1
	h2@0.4.6
	hashbrown@0.12.3
	hashbrown@0.15.1
	heck@0.3.3
	heck@0.4.1
	heck@0.5.0
	hermit-abi@0.1.19
	hermit-abi@0.3.9
	hermit-abi@0.4.0
	hex-simd@0.8.0
	hex@0.4.3
	http-body-util@0.1.2
	http-body@1.0.1
	http@1.1.0
	httparse@1.9.5
	hyper-rustls@0.27.3
	hyper-tls@0.6.0
	hyper-util@0.1.10
	hyper@1.5.0
	icu_collections@1.5.0
	icu_locid@1.5.0
	icu_locid_transform@1.5.0
	icu_locid_transform_data@1.5.0
	icu_normalizer@1.5.0
	icu_normalizer_data@1.5.0
	icu_properties@1.5.1
	icu_properties_data@1.5.0
	icu_provider@1.5.0
	icu_provider_macros@1.5.0
	ident_case@1.0.1
	idna@0.3.0
	idna@1.0.3
	idna_adapter@1.2.0
	indexmap@2.6.0
	inout@0.1.3
	ipnet@2.10.1
	itertools@0.13.0
	itoa@1.0.11
	js-sys@0.3.72
	keyboard-types@0.7.0
	ksni@0.2.2
	lazy_static@1.5.0
	libappindicator-sys@0.9.0
	libappindicator@0.9.0
	libc@0.2.162
	libdbus-sys@0.2.5
	libloading@0.7.4
	libloading@0.8.5
	libm@0.2.11
	libmimalloc-sys@0.1.39
	libredox@0.1.3
	libxdo-sys@0.11.0
	libxdo@0.6.0
	linux-raw-sys@0.4.14
	litemap@0.7.3
	litrs@0.4.1
	locale_config@0.3.0
	lock_api@0.4.12
	log@0.4.22
	lrc-nom@0.3.0
	lrclib-api-rs@0.3.1
	malloc_buf@0.0.6
	matchers@0.1.0
	md5@0.7.0
	memchr@2.7.4
	memoffset@0.9.1
	mimalloc@0.1.43
	mime@0.3.17
	minimal-lexical@0.2.1
	miniz_oxide@0.8.0
	mio@1.0.2
	mpris@2.0.1
	muda@0.15.3
	native-tls@0.2.12
	ncmapi2@0.1.13
	nix@0.29.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.45
	num-traits@0.2.19
	objc-foundation@0.1.1
	objc-sys@0.3.5
	objc2-app-kit@0.2.2
	objc2-core-data@0.2.2
	objc2-core-image@0.2.2
	objc2-encode@4.0.3
	objc2-foundation@0.2.2
	objc2-metal@0.2.2
	objc2-quartz-core@0.2.2
	objc2@0.5.2
	objc@0.2.7
	objc_id@0.1.1
	object@0.36.5
	once_cell@1.20.2
	opencc-rust@1.1.19
	openssl-macros@0.1.1
	openssl-probe@0.1.5
	openssl-sys@0.9.104
	openssl@0.10.68
	optfield@0.3.0
	option-ext@0.2.0
	ordered-stream@0.2.0
	outref@0.5.1
	overload@0.1.1
	pango-sys@0.18.0
	pango-sys@0.20.4
	pango@0.18.3
	pango@0.20.4
	parking@2.2.1
	parking_lot@0.12.3
	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-lite@0.2.15
	pin-utils@0.1.0
	piper@0.2.4
	pkcs1@0.7.5
	pkcs8@0.10.2
	pkg-config@0.3.31
	png@0.17.14
	polling@3.7.4
	pollster@0.3.0
	powerfmt@0.2.0
	ppv-lite86@0.2.20
	proc-macro-crate@1.3.1
	proc-macro-crate@2.0.0
	proc-macro-crate@3.2.0
	proc-macro-error-attr@1.0.4
	proc-macro-error@1.0.4
	proc-macro2@1.0.89
	psl-types@2.0.11
	ptr_meta@0.1.4
	ptr_meta_derive@0.1.4
	publicsuffix@2.2.3
	qqmusic-rs@0.2.1
	quick-xml@0.36.2
	quote@0.3.15
	quote@1.0.37
	radium@0.7.0
	rand@0.8.5
	rand_chacha@0.3.1
	rand_core@0.6.4
	raw-window-handle@0.6.2
	redox_syscall@0.5.7
	redox_users@0.4.6
	regex-automata@0.1.10
	regex-automata@0.4.8
	regex-syntax@0.6.29
	regex-syntax@0.8.5
	regex@1.11.1
	rend@0.4.2
	reqwest@0.12.9
	rfd@0.15.1
	ring@0.17.8
	rkyv@0.7.45
	rkyv_derive@0.7.45
	rsa@0.9.6
	rust_decimal@1.36.0
	rust_decimal_macros@1.36.0
	rustc-demangle@0.1.24
	rustc_version@0.4.1
	rustix@0.38.39
	rustls-pemfile@2.2.0
	rustls-pki-types@1.10.0
	rustls-webpki@0.102.8
	rustls@0.23.18
	rustversion@1.0.18
	ryu@1.0.18
	schannel@0.1.26
	scoped-tls@1.0.1
	scopeguard@1.2.0
	seahash@4.1.0
	security-framework-sys@2.12.1
	security-framework@2.11.1
	semver@1.0.23
	serde@1.0.215
	serde_derive@1.0.215
	serde_json@1.0.133
	serde_repr@0.1.19
	serde_spanned@0.6.8
	serde_urlencoded@0.7.1
	sha1@0.10.6
	sharded-slab@0.1.7
	shlex@1.3.0
	signal-hook-registry@1.4.2
	signature@2.2.0
	simd-adler32@0.3.7
	simdutf8@0.1.5
	siphasher@0.3.11
	slab@0.4.9
	smallvec@1.13.2
	socket2@0.5.7
	sorensen@0.2.0
	spin@0.9.8
	spki@0.7.3
	stable_deref_trait@1.2.0
	static_assertions@1.1.0
	strsim@0.10.0
	strsim@0.8.0
	strum@0.26.3
	strum_macros@0.26.4
	subtle@2.6.1
	syn@0.11.11
	syn@1.0.109
	syn@2.0.87
	sync_wrapper@1.0.1
	synom@0.11.3
	synstructure@0.13.1
	sys-locale@0.3.2
	system-configuration-sys@0.6.0
	system-configuration@0.6.1
	system-deps@6.2.2
	system-deps@7.0.3
	tap@1.0.1
	target-lexicon@0.12.16
	temp-dir@0.1.14
	tempfile@3.14.0
	textwrap@0.11.0
	thiserror-impl@1.0.69
	thiserror-impl@2.0.4
	thiserror@1.0.69
	thiserror@2.0.4
	thread_local@1.1.8
	time-core@0.1.2
	time-macros@0.2.18
	time@0.3.36
	tinystr@0.7.6
	tinyvec@1.8.0
	tinyvec_macros@0.1.1
	tokio-macros@2.4.0
	tokio-native-tls@0.3.1
	tokio-rustls@0.26.0
	tokio-util@0.7.12
	tokio@1.42.0
	toml@0.8.19
	toml_datetime@0.6.8
	toml_edit@0.19.15
	toml_edit@0.20.7
	toml_edit@0.22.22
	tower-service@0.3.3
	tracing-attributes@0.1.28
	tracing-core@0.1.33
	tracing-journald@0.3.1
	tracing-log@0.2.0
	tracing-panic@0.1.2
	tracing-subscriber@0.3.19
	tracing@0.1.41
	tray-icon@0.19.2
	try-lock@0.2.5
	typenum@1.17.0
	uds_windows@1.1.0
	unicode-bidi@0.3.17
	unicode-ident@1.0.13
	unicode-normalization@0.1.24
	unicode-segmentation@1.12.0
	unicode-width@0.1.14
	unicode-xid@0.0.4
	untrusted@0.9.0
	url@2.5.4
	urlencoding@2.1.3
	utf16_iter@1.0.5
	utf8_iter@1.0.4
	uuid@1.11.0
	valuable@0.1.0
	vcpkg@0.2.15
	vec_map@0.8.2
	version-compare@0.2.0
	version_check@0.9.5
	vsimd@0.8.0
	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.95
	wasm-bindgen-futures@0.4.45
	wasm-bindgen-macro-support@0.2.95
	wasm-bindgen-macro@0.2.95
	wasm-bindgen-shared@0.2.95
	wasm-bindgen@0.2.95
	wayland-backend@0.3.7
	wayland-client@0.31.7
	wayland-protocols@0.32.5
	wayland-scanner@0.31.5
	wayland-sys@0.31.5
	web-sys@0.3.72
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-x86_64-pc-windows-gnu@0.4.0
	winapi@0.3.9
	windows-core@0.58.0
	windows-implement@0.58.0
	windows-interface@0.58.0
	windows-registry@0.2.0
	windows-result@0.2.0
	windows-strings@0.1.0
	windows-sys@0.48.0
	windows-sys@0.52.0
	windows-sys@0.59.0
	windows-targets@0.48.5
	windows-targets@0.52.6
	windows@0.58.0
	windows_aarch64_gnullvm@0.48.5
	windows_aarch64_gnullvm@0.52.6
	windows_aarch64_msvc@0.48.5
	windows_aarch64_msvc@0.52.6
	windows_exe_info@0.4.2
	windows_i686_gnu@0.48.5
	windows_i686_gnu@0.52.6
	windows_i686_gnullvm@0.52.6
	windows_i686_msvc@0.48.5
	windows_i686_msvc@0.52.6
	windows_x86_64_gnu@0.48.5
	windows_x86_64_gnu@0.52.6
	windows_x86_64_gnullvm@0.48.5
	windows_x86_64_gnullvm@0.52.6
	windows_x86_64_msvc@0.48.5
	windows_x86_64_msvc@0.52.6
	winnow@0.5.40
	winnow@0.6.20
	winreg@0.52.0
	write16@1.0.0
	writeable@0.5.5
	wyz@0.5.1
	x11@2.21.0
	xdg-home@1.3.0
	xml-rs@0.8.23
	yoke-derive@0.7.4
	yoke@0.7.4
	zbus@4.4.0
	zbus@5.1.1
	zbus_macros@4.4.0
	zbus_macros@5.1.1
	zbus_names@3.0.0
	zbus_names@4.1.0
	zerocopy-derive@0.7.35
	zerocopy@0.7.35
	zerofrom-derive@0.1.4
	zerofrom@0.1.4
	zeroize@1.8.1
	zerovec-derive@0.10.3
	zerovec@0.10.4
	zvariant@4.2.0
	zvariant@5.1.0
	zvariant_derive@4.2.0
	zvariant_derive@5.1.0
	zvariant_utils@2.1.0
	zvariant_utils@3.0.2
"

declare -A GIT_CRATES=(
	[dark-light]='https://github.com/frewsxcv/rust-dark-light;3eb3e93dd0fa30733c3e93082dd9517fb580ae95;rust-dark-light-%commit%'
)

PLOCALES="en_US it_IT zh_CN"
PLOCALE_BACKUP="en_US"
RUST_MIN_VER="1.73"
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 CC-BY-4.0"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD GPL-3+ ISC MIT
	MPL-2.0 Unicode-3.0 Unicode-DFS-2016 Unlicense
"
SLOT="0"

DEPEND="
	dev-libs/glib:2
	app-i18n/opencc
	dev-libs/openssl:=
	gnome-base/dconf
	gui-libs/gtk:4
	sys-apps/dbus
	sys-devel/gettext
	x11-libs/cairo
"
RDEPEND="
	${DEPEND}
	sys-apps/xdg-desktop-portal
"

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 "${S}/metainfo/io.github.waylyrics.Waylyrics.gschema.xml"

	insinto "/usr/share/metainfo"
	doins "${S}/metainfo/io.github.waylyrics.Waylyrics.metainfo.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
}
