Optimus laptop issues


thank you, although im technically copy/paste/modifying plagiarizing :sunglasses: service/bash scripts from the “Writing systemd service units” thread you made or from arch wiki (both great resources)

still a great learning experience either way.


Actually service is not running the script after wake I think, I’ve tried adding Before=sleep.target and After=suspend.target to proper services but that didn’t change it.


on wake i believe it would be after suspend

Description=Network resume service
blah blah blah exec blah blah


i need not mention not to use the “bla blah blah” ??:grin:


I’m glad you did, I was already typing it :wink: Maybe my mind is playing tricks on me, I’m going to observe this for some time. I’ve put After=suspend.target in the service file already.


like above?

suspend.target represents the waking from sleep/suspend IIRC.

i guess you could have it wanted by/after graphical.target or network.target

@tbg this is the long walk off a short pier that is my knowledge of systemd units, the end is nigh :joy:


Yup, and it’s not working.

Description=Gpu off at wake




maybe this:


ExecStartPre=/usr/bin/sleep 15
ExecStart=/usr/bin/acpi_call [command goes here]


what is the exact acpi_call command? using a bash script may not be necessary??


echo _SB.PCI0.PEG0.PEGP._OFF | sudo tee /proc/acpi/call


Combined suspend-resume unit


so in that example it would run the commands specified by ExecStart= before sleep, and after waking would run the ExecStop= commands since sleep.target is stopped after resuming from sleep?? something like this?

#sudo systemctl enable gpu-on-off-sleep.service
#sudo systemctl start gpu-on-off-sleep.service
#sudo systemctl status gpu-on-off-sleep.service
#sudo systemctl daemon-reload

Description=nvidia gpu on/off hook

ExecStart=/usr/bin/echo '_SB.PCI0.PEG0.PEGP._ON | sudo tee /proc/acpi/call'
ExecStart=/usr/bin/sleep 10
ExecStop=/usr/bin/sleep 20
ExecStop=/usr/bin/echo '_SB.PCI0.PEG0.PEGP._OFF | sudo tee /proc/acpi/call'


ideally this would
run before sleep/suspend > turn on gpu > wait 10 seconds > sleep/suspend
and on wake it would
wait 20 second > disable gpu > stop ???


That’s what I thought!
I am an amateur wannabe @tlg @tbg:laughing:

It looks good.
A check would prove if it does the job :wink:


i think it would be
ExecStart=/usr/bin/echo '_SB.PCI0.PEG0.PEGP._ON | sudo tee /proc/acpi/call'
ExecStop=/usr/bin/echo '_SB.PCI0.PEG0.PEGP._OFF | sudo tee /proc/acpi/call'

instead of /bin/bash 'echo _SB.PCI0.PEG0.PEGP._OFF | sudo tee /proc/acpi/call'

edited post to match.

as a test from term:

~ >>> /usr/bin/echo "i am death, detroyer of gpu's" | tee ~/Downloads/servicetest.txt                                                                    
i am death, detroyer of gpu's
~ >>> cat ~/Downloads/servicetest.txt                                                                                                                    
i am death, detroyer of gpu's
~ >>>                                                                                                                                                    

:laughing: yup, works


Unfortunately that’s not working, it is freezing on sleep again. I’ve also tried these calls from terminal and they don’t do anything.

/usr/bin/echo '\_SB.PCI0.PEG0.PEGP._ON' | sudo tee /proc/acpi/call

this one does the job


i thought you tried them previously from terminal and they worked?

if they did work and are now no longer working, reboot, let the gpu shut off like it does 60s after boot. then try the on acpi call from terminal.

i think reason is that some of the commands from the .service never stopped


I must have messed the syntax, there is a lot happening atm. I will try to put the one i posted above in the service.


possibly, or you followed the example i made before i edited to the right one. dont forget to disable before edit and enable after or the service will just continue as it was before until it gets restarted.


No candy, I’ve tried the one you have posted,

/usr/bin/echo '\_SB.PCI0.PEG0.PEGP._ON' | sudo tee /proc/acpi/call


/usr/bin/echo '_SB.PCI0.PEG0.PEGP._ON' | sudo tee /proc/acpi/call

and none of them works, all freeze on suspend/sleep.
This one works from terminal but asks for password (may that be the issue?)

/usr/bin/echo '\_SB.PCI0.PEG0.PEGP._ON' | sudo tee /proc/acpi/call


running the command from terminal does it require sudo?

or in other words, can you power on/off the gpu without sudo?


It doesn’t require sudo but after issuing the command it asks for sudo password like so:

[jakub@jakub-pc ~]$ /usr/bin/echo '\_SB.PCI0.PEG0.PEGP._ON' | sudo tee /proc/acpi/call
[sudo] hasło użytkownika jakub: 
[jakub@jakub-pc ~]$ 


open a new terminal and try this
/usr/bin/echo '\_SB.PCI0.PEG0.PEGP._ON' | tee /proc/acpi/call

if it changes the power state of the gpu then sudo is not needed but im guessing sudo will be needed or at least asked for which i think would need to use a bash script like you were using before and have it set with the appropriate permissions/ownership like the one you have run at startup, that one needs privileged auth to run but it does not ask for it since it already has the permissions needed to run it as root. i dont know how to make a service behave that way on its own or if its possible.