Optimus laptop issues


#141

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.


#142

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.


#143

on wake i believe it would be after suspend

[Unit]
Description=Network resume service
After=suspend.target
[Service]
blah blah blah exec blah blah

[Install]
WantedBy=suspend.target

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


#144

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.


#145

both
After=suspend.target
and
WantedBy=suspend.target
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:


#146

Yup, and it’s not working.

[Unit]
Description=Gpu off at wake
After=suspend.target

[Service]
ExecStart=/usr/bin/turn_off_gpu_wake.sh 

[Install]
WantedBy=suspend.target   

#147

maybe this:

[Unit]
Description=gpuon
After=suspend.target
StopWhenUnneeded=yes

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=/usr/bin/sleep 15
ExecStart=/usr/bin/acpi_call [command goes here]


[Install]
WantedBy=suspend.target 

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


#148

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


#149

Combined suspend-resume unit


#150

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?

#/etc/systemd/system/gpu-on-off-sleep.service
#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

[Unit]
Description=nvidia gpu on/off hook
Before=sleep.target
StopWhenUnneeded=yes

[Service]
Type=oneshot
RemainAfterExit=yes
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'

[Install]
WantedBy=sleep.target

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 ???


#151

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:


#152

i think it would be
ExecStart=/usr/bin/echo '_SB.PCI0.PEG0.PEGP._ON | sudo tee /proc/acpi/call'
and
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


#153

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


#154

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


#155

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.


#156

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.


#157

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

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

and

/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

#158

running the command from terminal does it require sudo?

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


#159

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: 
\_SB.PCI0.PEG0.PEGP._ON
[jakub@jakub-pc ~]$ 


#160

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.