No sound from headphones Ubuntu 17.10 on 2013 iMac

When I plug in headphones to Ubuntu 17.10 on my iMac 2013 I don't get any sound out of the headset. The headphone jack/headphones work in MacOS so I know they aren't broken.

More interestingly, when I plug them in, it seems like Ubuntu detects it. The upper right volume icon in gnome when in the submenu changes to a headphone. The Settings | Sound changes from "Speakers" to "Headphones" and in Alsamixer the MM on the headphones switches to 00 and the speakers switch to MM automatically (and when I remove they automatically return to the other). However, still no sound emerges.

I've seen a number of answers here but none seem to fix. Here's my lspci | grep Audio output:

00:1b.0 Audio device: Intel Corporation 8 Series/C220 Series Chipset High Definition Audio Controller (rev 05)

01:00.1 Audio device: NVIDIA Corporation GK107 HDMI Audio Controller (rev a1)

I've tried $ alsactl restore and modifying /etc/modprobe.d/alsa-base.conf and then adding in the line options snd_hda_intel model=mb5 and rebooting. I've also tried rebooting both with and without headphones plugged in and to no avail. Sound works from speakers but not when headphones are hotplugged in. Any ideas how to fix this?

Thanks!


Okay after searching and searching I finally found an answer that works! I'll post the link and the summary here if anyone else has this issue.

https://ubuntuforums.org/showthread.php?p=12043359

The solution is to edit (as sudo) /etc/modprobe.d/alsa-base.conf and at the bottom of the file add the line options snd-hda-intel model=imac27_122 . I can't speak if this works for newer imacs or different sized imacs but it does work for the 2013 27" model on 17.10 as well.

(Note i tried options snd-hda-intel model=auto but that did not work.)