Askannz / optimus-manager

A Linux program to handle GPU switching on Optimus laptops.
MIT License
2.29k stars 168 forks source link

(using startx) How do I exactly run /usr/bin/prime-switch as root after the current user has logged out #404

Closed ndavd closed 3 months ago

ndavd commented 3 years ago

Could this be a bit more specific https://github.com/Askannz/optimus-manager/wiki/FAQ,-common-issues,-troubleshooting#i-do-not-use-a-display-manager-i-use-startx-or-xinit ?

karl-tye commented 3 years ago

First enable the prime-switch script to be executed from your account by appending this to /etc/sudoers

<username> ALL = NOPASSWD: /usr/bin/prime-switch

Then in your .xinitrc execute /usr/bin/prime-offload before your display manager. Also execute sudo /usr/bin/prime-switch after your display manager (executed when you log out). Mine looks like this

/usr/bin/prime-offload
ssh-agent dwm
sudo /usr/bin/prime-switch
ndavd commented 3 years ago

And by doing that are you sure it does what we want? Because it seems that it executes the script after the window manager starts

BachoSeven commented 3 years ago

@ndavidq0 it does exactly what described in the wiki, namely running a command just after xorg starts(but before dwm starts), and another one after it stops

ndavd commented 3 years ago

Thanks I'll try that

ndavd commented 3 years ago

This didn't work for me (i.e. after I do the switch command it logs off, I execute startx and get a black-screen)

/usr/bin/prime-offload
exec bspwm
sudo /usr/bin/prime-switch

What am I doing wrong here?

X-m7 commented 3 years ago

Does removing the exec bit work? So like:

/usr/bin/prime-offload
bspwm
sudo /usr/bin/prime-switch
es20490446e commented 3 months ago

Reopen if that doesn't work.