Name: power-options
Version: 1.2.2
Release: 1%{dist}
Summary: Linux GUI application for blazingly fast and simple power-management. 
License: MIT
URL: https://github.com/TheAlexDev23/power-options
Source0: https://github.com/TheAlexDev23/power-options/archive/refs/tags/v%{version}.tar.gz
Requires: acpid
Requires: gtk4
Requires: glib2
Requires: zsh
Requires: pciutils
Requires: usbutils
Requires: pango
Requires: yad
Recommends: xset
Recommends: xautolock
Recommends: xrandr
Recommends: brightnessctl
Recommends: net-tools
BuildRequires: rust
BuildRequires: cargo
BuildRequires: systemd-rpm-macros
BuildRequires: glib2-devel
BuildRequires: gtk4-devel
BuildRequires: graphene-devel
BuildRequires: libadwaita-devel

%description
All-In-One blazingly fast Linux GUI Application for simple and advanced power management on any device.Power Options can be a drop in replacement for any power-saving application, including TLP, auto-cpufreq, cpupower-gui, etc. Power Options covers all of the most common power saving settings and adds additional ones not present in any other application.

%prep
%autosetup
export RUSTUP_TOOLCHAIN=stable
cd crates/power-daemon-mgr
cargo fetch --target "$(rustc -vV | sed -n 's/host: //p')"
cd ../frontend-gtk
cargo fetch --target "$(rustc -vV | sed -n 's/host: //p')"


%build
export RUSTUP_TOOLCHAIN=stable
cd crates/power-daemon-mgr
cargo build --frozen --release

cd ../frontend-gtk
cargo build --frozen --release


%install
install -Dm755 "target/release/power-daemon-mgr" "%{buildroot}%{_bindir}/power-daemon-mgr"
"%{buildroot}%{_bindir}/power-daemon-mgr" -v generate-base-files --path "%{buildroot}" --program-path "%{_bindir}/power-daemon-mgr"

install -Dm755 "target/release/frontend-gtk" "%{buildroot}%{_bindir}/power-options-gtk"
install -Dm755 "icon.png" "%{buildroot}%{_datadir}/icons/power-options-gtk.png"
install -Dm755 "install/power-options-gtk.desktop" "%{buildroot}%{_datadir}/applications/power-options-gtk.desktop"


%files
%{_bindir}/power-daemon-mgr
%{_bindir}/power-options-gtk
%{_datadir}/icons/power-options-gtk.png
%{_datadir}/applications/power-options-gtk.desktop
%{_sysconfdir}/acpi/events/power-options
%{_prefix}/lib/systemd/system/power-options.service
%{_prefix}/lib/udev/rules.d/85-power-daemon.rules
%{_prefix}/share/dbus-1/system.d/power-daemon.conf

%post
%{_bindir}/power-daemon-mgr setup
%systemd_post power-options.service

%preun
%systemd_preun power-options.service
rm -rfv /etc/power-options

%postun
%systemd_postun_with_restart power-options.service

%changelog
* Tue Oct 29 2024 Leo Puvilland <luna@craftcat.dev> - 1.2.2
- Update to v1.2.2
* Fri Oct 25 2024 Leo Puvilland <luna@craftcat.dev> - 1.2.1-2
- Add setup script in postinst
* Thu Oct 24 2024 Leo Puvilland <luna@craftcat.dev> - 1.2.1-1
- Update to v1.2.1
* Wed Sep 18 2024 Leo Puvilland <luna@craftcat.dev> - 1.1.0
- Update to v1.1.0
* Mon Sep 16 2024 Leo Puvilland <luna@craftcat.dev> - 1.0.1
- Initial Package