I have installed Ubuntu 19.04 on my Huawei Matebook 13 and got everything working except automatic switching between laptop speakers and headphones. When they are plugged in, audio is still coming out of the speakers and they are not shown in settings. In fact the only partial solution to my problem was to install pavucontrol and manually switch the output to headphones. In pavucontrol, the headphones are shown as Unplugged, which means that the laptop does not recognize the headphones as being plugged in.
How can I fix my headphones not being recognized?