Closed st0nie closed 6 months ago
sudo mv this_file_path /usr/lib/systemd/system-sleep/legion
to make it working
require systemd, of course
tested on my machine
Now I create legion-linux-onresume.service
and it seems better
Just enable the service,legion-linux will auto restart on system resume
The reason why I use restart
instead of try-restart
is that legion-linux.service
will be inactive after a while, and try-restart
only restart service which is active
cc @MrDuartePT
That why I noticed some times systemd was degraded and the service failed to start. Thanks to find a solution I will just need to do some changes to the packaging.
That why I noticed some times systemd was degraded and the service failed to start. Thanks to find a solution I will just need to do some changes to the packaging.
IDK whether the fancurve-set will preserve its modification But changes made by ryzenadj will 100% lost after resume
https://gist.github.com/amanjeev/69eeb3a37aadb403542a16903fd60cbb
We can also introduce a timer to ensure the cpu tune is working
I giving a look now and my service was failing because I change to a kernel without the kernel module install. This seems to be a bug only with ryzenadj since the fan curve mantain after a suspend.
Well I also thinking of use the legion_cli.py as deamon instead of a seperate bash script, but we can add this systemd service in the mid time. The ryzenadj support just exist because some of cpu limit stuff in the gui dosen't work in some older model, so user can use ryzenadj to also set cpu option (and ryzenadj have more option), but it can be edit to other tool if you are using intel.
Well I also thinking of use the legion_cli.py as deamon instead of a seperate bash script, but we can add this systemd
legion-linux.service
as a daemon is probably better than now
Now this is a script and we cannot make sure it is really working after we exec it.
If it is a daemon, we can do some check after /sys/firmware/acpi/platform_profile
changed and or pluged off the AC
After all, daemon is simpler for user, they just need to enable the service, and legion-linux daemon
do all the things
just a quick note also work in /usr/lib/systemd/system/legion-linux-onresume.service
mrduarte@GentooLegion ~/mrduarte-github/guru/sys-firmware/lenovolegionlinux (dev) $ systemctl status legion-linux-onresume.service
○ legion-linux-onresume.service - Restart legion-linux on resume
Loaded: loaded (/usr/lib/systemd/system/legion-linux-onresume.service; enabled; preset: disabled)
Active: inactive (dead)
Mar 10 18:09:06 GentooLegion systemd[1]: Finished Restart legion-linux on resume.
Mar 10 18:09:11 GentooLegion systemd[1]: Stopping Restart legion-linux on resume...
Mar 10 18:09:11 GentooLegion systemd[1]: legion-linux-onresume.service: Deactivated successfully.
Mar 10 18:09:11 GentooLegion systemd[1]: Stopped Restart legion-linux on resume.
mrduarte@GentooLegion ~/mrduarte-github/guru/sys-firmware/lenovolegionlinux (dev) $ systemctl status legion-linux.service
○ legion-linux.service - Apply Fan Curve to Lenovo Legion Laptop depending on Power State and Charger Mode (LenovoLegi>
Loaded: loaded (/usr/lib/systemd/system/legion-linux.service; enabled; preset: disabled)
Active: inactive (dead) since Sun 2024-03-10 18:09:12 WET; 10s ago
Duration: 672ms
TriggeredBy: ● legion-linux.path
Process: 85712 ExecStart=/usr/bin/fancurve-set (code=exited, status=0/SUCCESS)
Main PID: 85712 (code=exited, status=0/SUCCESS)
CPU: 663ms
Mar 10 18:09:11 GentooLegion systemd[1]: Starting Apply Fan Curve to Lenovo Legion Laptop depending on Power State and>
Mar 10 18:09:11 GentooLegion systemd[1]: Started Apply Fan Curve to Lenovo Legion Laptop depending on Power State and >
Mar 10 18:09:11 GentooLegion fancurve-set[85712]: Applying Performance Mode Profile 龍 -> charger...
Mar 10 18:09:12 GentooLegion fancurve-set[85730]: Successfully wrote preset /etc/legion_linux//performance-ac to hardw>
Mar 10 18:09:12 GentooLegion systemd[1]: legion-linux.service: Deactivated successfully.
mrduarte@GentooLegion ~/mrduarte-github/guru/sys-firmware/lenovolegionlinux (dev) $
Some modifications, such as the changes made by ryzenadj, cannot be preserved after the machine goes through the suspend-resume cycle. Therefore, we can create a file to allow the Legion service to automatically start once the machine resumes.