Fixup

parent b57eefa4
#!/bin/bash
echo "$(date)" > /var/log/end_session.log
kill -9 $(ps aux | grep "pactl_watch\|pactl.*subscribe" | awk '{print $2}')
#!/bin/bash
cat <<EOF > /etc/modprobe.d/alsa-base.conf
options snd-hda-intel model=generic
EOF
echo "Pour prise en compte de la configuration de son, un redémarrage peut être nécessaire"
sed -i \
-e 's/^options snd-hda-intel model=generic$/options snd-hda-intel model=auto/' \
/etc/modprobe.d/alsa-base.conf
kmajor=$(uname -r | cut -d '.' -f 1)
kminor=$(uname -r | cut -d '.' -f 2)
echo $kver
if (( $(echo "$kmajor <= 4" | bc -l) )) && (( $(echo "$kminor < 19" | bc -l) ))
then
rm /etc/modprobe.d/alsa-base.conf
echo "deb http://deb.debian.org/debian stretch-backports main" \
> /etc/apt/sources.list.d/backports.list
apt-get update
pkg=$(apt-cache search "linux-image-4.19.*[0-9]-amd64" | \
sort -n | grep -v "amd64-.*" | tail -n 1 | awk '{print $1}')
apt-get install -y $pkg
echo "Pour prise en compte de la configuration de son, un redémarrage peut être nécessaire"
else
echo "kernel $kmajor.$kminor >= to 4.19, doing nothing"
fi
sed -i -e 's@^#\(session-cleanup-script=\)@\1/opt/primtux-eole/end_session.sh@' /etc/lightdm/lightdm.conf
......@@ -4,16 +4,35 @@
user=$(who | grep -v "root" | head -n 1 | cut -d ' ' -f 1)
if [ ! -z "$user" ]
then
export DISPLAY=:0
export XAUTHORITY="/home/$user/.Xauthority"
id=$(id -u $user)
export DISPLAY=:0
export XAUTHORITY="/home/$user/.Xauthority"
fi
pulsecmd(){
cmd=$1
shift
if [ $cmd == "pactl" ]
then
cmd="$cmd --server unix:/run/user/$id/pulse/native"
fi
# set -x
if [ "$(whoami)" != "root" ]
then
$cmd $@
else
sudo -u $user XDG_RUNTIME_DIR="/run/user/$id/" $cmd $@
fi
# set +x
}
HDMI_STATUS=`grep "^connected$" /sys/class/drm/card0/*HDMI*/status`
INPUTS=$(pacmd list-sink-inputs | grep index | awk '{print $2}')
HEADPHONE_STATUS=`pulsecmd pacmd list-sinks | grep "headphones.*available: yes"`
INPUTS=$(pulsecmd pacmd list-sink-inputs | grep index | awk '{print $2}')
# Compute output name
echo $INPUTS
if [ ! -z $HDMI_STATUS ]
if [ ! -z $HDMI_STATUS ] && [ -z "$HEADPHONE_STATUS" ]
then
name="hdmi"
plusname=".monitor"
......@@ -25,42 +44,38 @@ fi
name="$name-stereo"
echo "name $name"
card=`pacmd list-cards | grep device.bus_path | head -n 1 | awk '{print $3}' \
card=`pulsecmd pacmd list-cards | grep device.bus_path | head -n 1 | awk '{print $3}' \
| sed -e 's/"//g' -e 's/:/_/g' `
echo "card $card"
output="alsa_output.$card.$name"
echo "out $output"
io=`pacmd list-cards | grep "output:$name.*input:" | awk '{print $1}' \
io=`pulsecmd pacmd list-cards | grep "output:$name.*input:" | awk '{print $1}' \
| head -n 1 | sed 's/:$//' `
if [ -z "$io" ]
then
# Io does not support input mode
io=`pacmd list-cards | grep "output:$name" | awk '{print $1}' \
io=`pulsecmd pacmd list-cards | grep "output:$name" | awk '{print $1}' \
| head -n 1 | sed 's/:$//' `
fi
echo "io $io"
# Iterate over all cardes
for i in seq 0 $(($(pacmd list-cards | grep index |wc -l)-1))
for i in $(seq 0 $(($(pulsecmd pacmd list-cards | grep index |wc -l)-1)))
do
#set -x
# Set profile or turn card off
pactl set-card-profile $i $io
pulsecmd pactl set-card-profile $i $io
if [ $? -ne 0 ]
then
pactl set-card-profile $i off
pulsecmd pactl set-card-profile $i off
else
pactl set-default-sink $output
pactl set-source-mute alsa_$type.$card.$name$plusname 1
pulsecmd pactl set-default-sink $output
pulsecmd pactl set-source-mute alsa_$type.$card.$name$plusname 1
fi
#set +x
done
# Move all sources to the right sink
for i in $INPUTS
do
#set -x
pacmd move-sink-input $i $output
#set +x
pulsecmd pacmd move-sink-input $i $output
done
#!/bin/bash
DIR=$(realpath $(dirname $0))
user=$(who | grep -v "root" | head -n 1 | cut -d ' ' -f 1)
if [ ! -z "$user" ]
then
id=$(id -u $user)
export DISPLAY=:0
export XAUTHORITY="/home/$user/.Xauthority"
fi
pacmd(){
# set -x
cmd="pactl --server unix:/run/user/$id/pulse/native $@"
if [ "$(whoami)" != "root" ]
then
$cmd
else
sudo -u $user XDG_RUNTIME_DIR="/run/user/$id/" $cmd
fi
# set +x
}
date=$(date +%Y%m%d%H%M%S)
pacmd subscribe | while read line
do
ndate=$(date +%Y%m%d%H%M%S)
if [ $ndate != $date ]
then
$DIR/hdmi_sound_toggle.sh
fi
date=$ndate
done
......@@ -121,4 +121,3 @@ done
# Actually do stuff
$cmd
$DIR/hdmi_sount_toggle.sh
......@@ -5,6 +5,10 @@ SCOPE2=CE1-CE2
SCOPE3=CM1-CM2
SHARE_DIR="/home/shares/$USER"
# unmute sound
pactl set-sink-mute 0 0
/opt/primtux-eole/pactl_watch.sh &
while ! /bin/ping -c 2 ecole-dc; do sleep 10; done;
for d in 01-cp 02-ce1-ce2 03-cm1-cm2
......@@ -66,6 +70,3 @@ case "$USER" in
echo file://$DOCUMENTS/CONFIDENTIEL_PROFESSEURS CONFIDENTIEL_PROFESSEURS >> $HOME/.config/gtk-3.0/bookmarks
;;
esac
# unmute sound
pactl set-sink-mute 0 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment