commit:     92e292680eb33e306848bb17f3c60919078f6488
Author:     Gonçalo Negrier Duarte <gonegrier.duarte <AT> gmail <DOT> com>
AuthorDate: Sun Mar 17 13:38:49 2024 +0000
Commit:     Gonçalo Negrier Duarte <gonegrier.duarte <AT> gmail <DOT> com>
CommitDate: Sun Mar 17 13:41:11 2024 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=92e29268

sys-firmware/lenovolegionlinux: add openrc support and improve ebuild
* thanks to @st0nie

Closes: https://github.com/johnfanv2/LenovoLegionLinux/issues/181
Signed-off-by: Gonçalo Negrier Duarte <gonegrier.duarte <AT> gmail.com>

 .../lenovolegionlinux/files/legiond-onresume.sh    |  6 ++++++
 sys-firmware/lenovolegionlinux/files/legiond.initd |  7 +++++++
 .../lenovolegionlinux-9999.ebuild                  | 23 ++++++++++++++--------
 sys-firmware/lenovolegionlinux/metadata.xml        |  7 ++++---
 4 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/sys-firmware/lenovolegionlinux/files/legiond-onresume.sh 
b/sys-firmware/lenovolegionlinux/files/legiond-onresume.sh
new file mode 100644
index 0000000000..2c311aabb5
--- /dev/null
+++ b/sys-firmware/lenovolegionlinux/files/legiond-onresume.sh
@@ -0,0 +1,6 @@
+#!/BIN/bash
+case $1/$2 in
+post/*)
+       /usr/bin/legiond-cli fanset 3
+       ;;
+esac

diff --git a/sys-firmware/lenovolegionlinux/files/legiond.initd 
b/sys-firmware/lenovolegionlinux/files/legiond.initd
new file mode 100644
index 0000000000..a95e50bd92
--- /dev/null
+++ b/sys-firmware/lenovolegionlinux/files/legiond.initd
@@ -0,0 +1,7 @@
+#!/sbin/openrc-run
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+command="/usr/bin/legiond"
+command_background=true
+pidfile="/run/legiond.pid"

diff --git a/sys-firmware/lenovolegionlinux/lenovolegionlinux-9999.ebuild 
b/sys-firmware/lenovolegionlinux/lenovolegionlinux-9999.ebuild
index a98d9f643f..58270c5e48 100644
--- a/sys-firmware/lenovolegionlinux/lenovolegionlinux-9999.ebuild
+++ b/sys-firmware/lenovolegionlinux/lenovolegionlinux-9999.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2023 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
@@ -8,7 +8,7 @@ M_PN=LenovoLegionLinux
 DISTUTILS_USE_PEP517=setuptools
 PYTHON_COMPAT=(python3_{9..12})
 
-inherit linux-mod-r1 distutils-r1 systemd
+inherit linux-mod-r1 distutils-r1 systemd optfeature
 
 if [[ ${PV} == "9999" ]]; then
        EGIT_REPO_URI="https://github.com/johnfanv2/${M_PN}.git";
@@ -37,18 +37,13 @@ RDEPEND="
                sys-power/acpid
        )
        downgrade-nvidia? ( <=x11-drivers/nvidia-drivers-525 )
-       radeon-dgpu? ( dev-util/rocm-smi )
-       ryzenadj? ( sys-power/RyzenAdj )
-       undervolt-intel? ( dev-python/undervolt )
 "
 
 DEPEND="${RDEPEND}"
 
 LICENSE="GPL-2"
 SLOT="0"
-IUSE="+gui radeon-dgpu downgrade-nvidia ryzenadj undervolt-intel"
-REQUIRED_USE="|| ( radeon-dgpu downgrade-nvidia ryzenadj gui undervolt-intel ) 
radeon-dgpu? ( !downgrade-nvidia gui ) downgrade-nvidia? ( !radeon-dgpu gui ) 
undervolt-intel? ( !ryzenadj gui ) ryzenadj? ( !undervolt-intel gui )"
-
+IUSE="+gui downgrade-nvidia elogin"
 MODULES_KERNEL_MIN=5.10
 
 src_compile() {
@@ -83,6 +78,14 @@ src_install() {
                cd "${WORKDIR}/${P}/extra" || die
 
                systemd_dounit service/legiond.service 
service/legiond-onresume.service
+
+        newinitd "${FILESDIR}/legiond.initd" legiond
+
+        if use elogind; then
+            exeinto /lib64/elogind/system-sleep/
+            doexe "${FILESDIR}/legiond-onresume.sh"
+        fi
+
                insinto /etc/acpi/events
                doins acpi/events/{legion_ppd,legion_ac}
                dobin service/legiond/legiond
@@ -105,4 +108,8 @@ pkg_postinst() {
        ewarn "Note for 2023-2023 Legion user: It need help for testing the 
features"
        ewarn "Pls test the feature how is decribe in the README of the 
project!"
        ewarn "and also go to this issue in github: 
https://github.com/johnfanv2/LenovoLegionLinux/issues/46";
+
+    optfeature "radeon dgpu power management" dev-util/rocm-smi
+    optfeature "ryzen CPU tweaks" sys-power/RyzenAdj
+    optfeature "intel CPU tweaks" dev-python/undervolt
 }

diff --git a/sys-firmware/lenovolegionlinux/metadata.xml 
b/sys-firmware/lenovolegionlinux/metadata.xml
index bd4ddf3020..a98adf9979 100644
--- a/sys-firmware/lenovolegionlinux/metadata.xml
+++ b/sys-firmware/lenovolegionlinux/metadata.xml
@@ -3,14 +3,15 @@
 <pkgmetadata>
        <use>
                <flag name="gui">Build and install legion_gui and 
legion_cli</flag>
-               <flag name="radeon-dgpu">Enable AMD GPU TDP control 
(systemd-service)</flag>
                <flag name="downgrade-nvidia">Downgrade nvidia for 525 to 
enable TDP control (systemd-service)</flag>
-               <flag name="ryzenadj">[AMD] CPU and APU control using ryzenadj 
(systemd-service)</flag>
-               <flag name="undervolt-intel">[INTEL] CPU and APU control using 
undervolt (systemd-service)</flag>
+               <flag name="elogind">Enable legiond-onresume openrc 
support</flag>
        </use>
        <maintainer type="person">
                <email>[email protected]</email>
                <name>Gonçalo Negrier Duarte</name>
+       <maintainer type="person">
+               <email>[email protected]</email>
+               <name>ston</name>
        </maintainer>
        <upstream>
                <remote-id type="github">johnfanv2/LenovoLegionLinux</remote-id>

Reply via email to