post_install() {
    if grep -q "options snd-hda-intel model=headset-mode" /etc/modprobe.d/alsa-base.conf &>/dev/null; then
        sed -i 's/options snd-hda-intel model=headset-mode//g' /etc/modprobe.d/alsa-base.conf
        echo "options snd-hda-intel model=dell-headset-multi" &>> /etc/modprobe.d/alsa-base.conf
    elif ! grep -q "options snd-hda-intel model=dell-headset-multi" /etc/modprobe.d/alsa-base.conf &>/dev/null; then
        echo "options snd-hda-intel model=dell-headset-multi" &>> /etc/modprobe.d/alsa-base.conf
    fi
}

post_upgrade() {
    post_install

    # use synaptics driver for clickpads
    _confdir=/etc/X11/xorg.conf.d/
    if [[ "$(vercmp $2 1.2)" -lt 0 ]]; then
        [[ -e $_confdir/30-touchpad.conf ]] && mv $_confdir/30-touchpad.conf $_confdir/30-touchpad.conf.bak
        if [[ ! -e $_confdir/70-synaptics.conf ]]; then
            cat <<EOF > $_confdir/70-synaptics.conf
Section "InputClass"
    Identifier "touchpad"
    Driver "synaptics"
    MatchIsTouchpad "on"
        Option "TapButton1" "1"
        Option "TapButton2" "3"
        Option "TapButton3" "2"
EndSection
EOF
        fi
    fi
}

post_remove() {
    if grep -q "options snd-hda-intel model=headset-mode" /etc/modprobe.d/alsa-base.conf; then
        sed -i 's/options snd-hda-intel model=headset-mode//g' /etc/modprobe.d/alsa-base.conf
    elif grep -q "options snd-hda-intel model=dell-headset-multi" /etc/modprobe.d/alsa-base.conf; then
        sed -i 's/options snd-hda-intel model=dell-headset-multi//g' /etc/modprobe.d/alsa-base.conf
    fi
}
