I posted this on AskUbuntu, but I didn't get any responses

I am dual booting Ubuntu 22.04.1 on a Lenovo laptop. I have an external monitor that I use as my primary display. Up until a month or two ago, everything was working fine. I would start up my computer, and it would know that my external monitor is connected through HDMI and that is my primary display.


Then (I think after some update) it just stopped working. Now when I start up my computer, my external monitor just displays a black screen. My built-in screen shows the desktop, but it doesn't have the taskbar, so it's still being treated as my secondary display.
In order to fix it, I have to unplug and replug the HDMI once so that my built-in screen becomes the primary display. But at this point my second monitor still just displays a black screen. Then I have to unplug and replug the HDMI once more to get my external monitor working correctly as the primary display.


I am using nvidia-driver-525 (proprietary). I read somewhere that disabling secure boot would solve this problem, but I did, and it didn't work.