#!/bin/bash

FICHVARS="/etc/default/vx-dga-variables/vx-dga-variables-general.conf"
[ -f "${FICHVARS}" ] && . "${FICHVARS}"
USUARIO="$(vx-usuario-grafico)"
if [[ "${USUARIO}" == "profesor" && -z "${CONFTARJETASONIDO}" ]] && \
grep -q "HDMI" "/proc/asound/cards" ; then
    
    cat > "/home/profesor/.asoundrc"<<EOF
pcm.!default {
 type hw
 card PCH
}

ctl.!default {
 type hw
 card PCH
}
EOF
    chown "profesor" "/home/profesor/.asoundrc"
    #chmod 644 /home/profesor/.asoundrc
    [[ -f "/etc/init.d/alsa-utils" ]] && /etc/init.d/alsa-utils restart
    sed -i '/Varibles utilizadas por los paquetes/a CONFTARJETASONIDO=1' "${FICHVARS}"
fi