From d3a6267c6ff1b476669761af0f94f93c4737ecd4 Mon Sep 17 00:00:00 2001 From: Gonçalo Negrier Duarte Date: Wed, 5 Jul 2023 08:37:51 +0100 Subject: sys-firmware/lenovolegionlinux: new package, add 9999 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add keyword for ~amd64 ~x86 Signed-off-by: Gonçalo Negrier Duarte --- sys-firmware/lenovolegionlinux/files/cpu | 12 +++ .../lenovolegionlinux/files/legion_cli.policy | 19 ++++ .../lenovolegionlinux/files/legion_gui.desktop | 9 ++ sys-firmware/lenovolegionlinux/files/nvidia | 12 +++ sys-firmware/lenovolegionlinux/files/radeon | 12 +++ .../lenovolegionlinux-9999.ebuild | 100 +++++++++++++++++++++ sys-firmware/lenovolegionlinux/metadata.xml | 17 ++++ 7 files changed, 181 insertions(+) create mode 100644 sys-firmware/lenovolegionlinux/files/cpu create mode 100644 sys-firmware/lenovolegionlinux/files/legion_cli.policy create mode 100644 sys-firmware/lenovolegionlinux/files/legion_gui.desktop create mode 100644 sys-firmware/lenovolegionlinux/files/nvidia create mode 100644 sys-firmware/lenovolegionlinux/files/radeon create mode 100644 sys-firmware/lenovolegionlinux/lenovolegionlinux-9999.ebuild create mode 100644 sys-firmware/lenovolegionlinux/metadata.xml (limited to 'sys-firmware') diff --git a/sys-firmware/lenovolegionlinux/files/cpu b/sys-firmware/lenovolegionlinux/files/cpu new file mode 100644 index 000000000..76224d3fa --- /dev/null +++ b/sys-firmware/lenovolegionlinux/files/cpu @@ -0,0 +1,12 @@ +#!/bin/bash + +# Remove the comment for your configuration + +#RYZEN (Cpu TDP control using RyzenADJ) +#INTEL (Cpu control using undervolt) [https://github.com/georgewhewell/undervolt] +#Disable by default see the github from both project +CPU_Control=0 +#NVIDIA (nvidia-smi) +#TEAM_GREEN=1 +#AMD (rocm-smi) +#TEAM_RED=1 \ No newline at end of file diff --git a/sys-firmware/lenovolegionlinux/files/legion_cli.policy b/sys-firmware/lenovolegionlinux/files/legion_cli.policy new file mode 100644 index 000000000..c19c64c55 --- /dev/null +++ b/sys-firmware/lenovolegionlinux/files/legion_cli.policy @@ -0,0 +1,19 @@ + + + + + + Authentication is required to run legion_cli + legion_cli + + auth_admin_keep + auth_admin_keep + auth_admin_keep + + /usr/bin/legion_cli + true + + + diff --git a/sys-firmware/lenovolegionlinux/files/legion_gui.desktop b/sys-firmware/lenovolegionlinux/files/legion_gui.desktop new file mode 100644 index 000000000..48b17927d --- /dev/null +++ b/sys-firmware/lenovolegionlinux/files/legion_gui.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Name=LenovoLegionLinux +Icon=/usr/share/pixmaps/legion_logo.png +Exec=legion_gui --use_legion_cli_to_write +Comment=Control Lenovo Legion Laptops +Categories=System +Terminal=false diff --git a/sys-firmware/lenovolegionlinux/files/nvidia b/sys-firmware/lenovolegionlinux/files/nvidia new file mode 100644 index 000000000..93d3f0824 --- /dev/null +++ b/sys-firmware/lenovolegionlinux/files/nvidia @@ -0,0 +1,12 @@ +#!/bin/bash + +# Remove the comment for your configuration + +#RYZEN (Cpu TDP control using RyzenADJ) +#INTEL (Cpu control using undervolt) [https://github.com/georgewhewell/undervolt] +#Disable by default see the github from both project +#CPU_Control=0 +#NVIDIA (nvidia-smi) +TEAM_GREEN=1 +#AMD (rocm-smi) +#TEAM_RED=1 \ No newline at end of file diff --git a/sys-firmware/lenovolegionlinux/files/radeon b/sys-firmware/lenovolegionlinux/files/radeon new file mode 100644 index 000000000..660f9f881 --- /dev/null +++ b/sys-firmware/lenovolegionlinux/files/radeon @@ -0,0 +1,12 @@ +#!/bin/bash + +# Remove the comment for your configuration + +#RYZEN (Cpu TDP control using RyzenADJ) +#INTEL (Cpu control using undervolt) [https://github.com/georgewhewell/undervolt] +#Disable by default see the github from both project +#CPU_Control=0 +#NVIDIA (nvidia-smi) +#TEAM_GREEN=1 +#AMD (rocm-smi) +TEAM_RED=1 \ No newline at end of file diff --git a/sys-firmware/lenovolegionlinux/lenovolegionlinux-9999.ebuild b/sys-firmware/lenovolegionlinux/lenovolegionlinux-9999.ebuild new file mode 100644 index 000000000..9160a2f76 --- /dev/null +++ b/sys-firmware/lenovolegionlinux/lenovolegionlinux-9999.ebuild @@ -0,0 +1,100 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DISTUTILS_USE_PEP517=setuptools +PYTHON_COMPAT=( python3_{9..11} ) + +EPYTHON=python3 + +inherit linux-mod-r1 toolchain-funcs git-r3 distutils-r1 desktop systemd + +EGIT_REPO_URI="https://github.com/johnfanv2/LenovoLegionLinux.git" + +DESCRIPTION="Lenovo Legion Linux kernel module" +HOMEPAGE="https://github.com/johnfanv2/LenovoLegionLinux" + +DEPEND="sys-kernel/linux-headers + sys-apps/lm-sensors + sys-apps/dmidecode + legion-tools? ( dev-python/PyQt5 ) + legion-tools? ( dev-python/pyyaml ) + legion-tools? ( dev-python/argcomplete ) + app-portage/smart-live-rebuild + legion-acpi? ( sys-power/acpid ) + radeon-dgpu? ( dev-util/rocm-smi ) + downgrade-nvidia? ( <=x11-drivers/nvidia-drivers-525 ) + ryzenadj? ( sys-power/RyzenAdj )" +LICENSE="GPL-2" +SLOT="0" +IUSE="legion-tools legion-acpi systemd radeon-dgpu downgrade-nvidia ryzenadj" +REQUIRED_USE="|| ( systemd legion-acpi radeon-dgpu downgrade-nvidia ryzenadj legion-tools ) legion-acpi? ( legion-tools ) radeon-dgpu? ( !downgrade-nvidia legion-tools ) downgrade-nvidia? ( !radeon-dgpu legion-tools )" + +KEYWORDS="~amd64~x86" + +MODULES_KERNEL_MIN=5.10 + +src_compile() { + local modlist=( + legion-laptop=kernel/drivers/platform/x86:kernel_module:kernel_module:all + ) + KERNELVERSION=${KV_FULL} linux-mod-r1_src_compile + if use legion-tools; then + #Define build dir (fix sandboxed) + cd "${WORKDIR}/${P}/python/legion_linux" + distutils-r1_src_compile --build-dir "${WORKDIR}/${P}/python/legion_linux/build" + fi +} + +src_install() { + linux-mod-r1_src_install + #Load the module without reboot + cd "${WORKDIR}/${P}/python/legion_linux/" + make forcereloadmodule + if use legion-tools; then + #Define build dir (fix sandboxed) + cd "${WORKDIR}/${P}/python/legion_linux/" + distutils-r1_src_install --build-dir "${WORKDIR}/${P}/python/legion_linux/build" + + cd "${WORKDIR}/${P}/extra" + + if use legion-acpi; then + insinto /etc/acpi/events/ && doins acpi/events/{ac_adapter_legion-fancurve,novo-button,PrtSc-button,fn-r-refrate} + insinto /etc/acpi/actions/ && doins acpi/actions/{battery-legion-quiet.sh,snipping-tool.sh,fn-r-refresh-rate.sh} + fi + + if use systemd; then + systemd_dounit service/legion-linux.service service/legion-linux.path + dobin service/fancurve-set + insinto /usr/share/legion_linux && doins service/profiles/* + insinto /etc/legion_linux && doins service/profiles/* + + #AMD + if use radeon-dgpu; then + insinto /usr/share/legion_linux && newins "${FILESDIR}/radeon" .env + insinto /etc/legion_linux && newins "${FILESDIR}/radeon" .env + fi + #NVIDIA (need dowgrade because nvidia-smi -pl was removed) + if use downgrade-nvidia; then + insinto /usr/share/legion_linux && newins "${FILESDIR}/nvidia" .env + insinto /etc/legion_linux && newins "${FILESDIR}/nvidia" .env + fi + + if use ryzenadj; then + insinto /usr/share/legion_linux && newins "${FILESDIR}/cpu" .env + insinto /etc/legion_linux && newins "${FILESDIR}/cpu" .env + fi + + elog "IMPORTANT!!!!\nPls copy /usr/share/legion_linux folder to .config in your Home folder\n Dont forget to edit .config/legion_linux/.env" + fi + + # Desktop Files and Polkit + domenu "${FILESDIR}/legion_gui.desktop" + doicon "${WORKDIR}/${P}/python/legion_linux/legion_linux/legion_logo.png" + insinto "/usr/share/polkit-1/actions/" && doins "${FILESDIR}/legion_cli.policy" + + fi + + elog "INTEL USERS!!!!\nCPU Control Feature: On intel cpu install undervolt https://github.com/georgewhewell/undervolt (or other tool you like to use). More information read the readme https://github.com/Petingoso/legion-fan-utils-linux/blob/main/README.md" +} diff --git a/sys-firmware/lenovolegionlinux/metadata.xml b/sys-firmware/lenovolegionlinux/metadata.xml new file mode 100644 index 000000000..479623d1d --- /dev/null +++ b/sys-firmware/lenovolegionlinux/metadata.xml @@ -0,0 +1,17 @@ + + + + + Build and install legion_gui and legion_cli + Install acpi script (experimental feature) + Enable AMD GPU TDP control (systemd-service) + Downgrade nvidia for 525 to enable TDP control (systemd-service) + CPU and APU control using ryzenadj (systemd-service) + + + johnfanv2/LenovoLegionLinux + https://github.com/johnfanv2/LenovoLegionLinux/issues + https://github.com/johnfanv2/LenovoLegionLinux/blob/main/README.md + + + -- cgit v1.2.3-65-gdbad