I was setting up Bumblee with primus to switch between my discrete/integrated GPUs using the Arch Wiki as a guide when I saw this:
Note: Since compositing hurts performance, invoking primus when a compositing WM is active is not recommended. See #Primus issues under compositing window managers.
I use the Compton compositor with i3, so I want to disable Compton whenever primusrun or optirun is invoked and re-enable it when primusrun/optirun are not used.
How could I do this with a bash script or systemd?
I started by writing writing a user level systemd service file for Compton with the idea that I could write a service file for primusrun/optirun that
Conflicts= with Compton and starts it again after exiting. But the problem is that primusrun/optirun take an application as an argument and run that using the discrete GPU. So their use doesn't seem compatible with starting a service that invokes them.
Any solutions to this? To re-state the core issue: I want to automatically stop the Compton process when primusrun/optirun are started and restart Compton when they are killed.