On my 9750 running Ubuntu 18.04, whenever I turn off the dgpu using bbswitch before logging in or on boot, my system freezes.
After trying many different methods and many reboots I settled on a workaround: scheduling a cron job to activate bbswitch after some delay (60s) on reboot, so that I can login before bbswitch kicks in.
open crontab as root in terminal:
sudo crontab -e
add to cron:
@reboot sleep 60 && /sbin/modprobe bbswitch
replace /sbin/modprobe to where your modprobe executable is, this assumes bbswitch is installed.
Also add to /etc/modprobe.d/bbswitch.conf:
options bbswitch load_state=0 unload_state=1
This turns off the dgpu on loading bbswitch and turns in on on unloading bbswitch. Refer to here for more details.
For the lid problem, I had to edit logind.conf:
sudo nano /etc/systemd/logind.conf
change the following line:
HandleLidSwitchDocked=ignore
to
HandleLidSwitchDocked=suspend
Strangely if you leave the default settings (=ignore), attach an external display and shut the lid the computer does not freeze on reopening. With =ignore and with an external display the computer suspends when you close the lid but you can wake the external monitor with your mouse/keyboard.
Best Answer