#!/bin/bash
#changeMonitors="false"; #(Links)
changeMonitors="true"; #(Rechts)
dontChangeAudio="false";
noPresentationMode="false";
while [ -n "$1" ]; do
[ "-n" = "$1" -o "--dontChangeAudio" = "$1" ] && dontChangeAudio="true";
[ "-p" = "$1" -o "--noPresentationMode" = "$1" ] && noPresentationMode="true";
shift;
done
Ports=$(xrandr | grep -P "DisplayPort-[0-9]+ connected" | sed -e "s/ .*$//");
myArr+=($Ports);
if [ -z "${myArr[1]}" ]; then
if [ -n "${myArr[0]}" ]; then
echo "Nur einen externen Monitor gefunden. Aktiviere gefundenen Monitor..." 1>&2;
/usr/bin/xrandr \
--output ${myArr[0]} --primary --scale 1.0 --mode 1920x1080 --rate 60 --pos 0x0 --rotate normal \
--output eDP --off
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor${myArr[0]}/workspace0/last-image -s /home/fastix/Bilder/Wallpaper/Papagei.jpg
else
echo "Keinen externen Monitor gefunden. Exit!" 1>&2;
exit 2
fi
else
if [ $changeMonitors = "true" ]; then
dp1=${myArr[0]};
dp2=${myArr[1]};
else
dp1=${myArr[1]};
dp2=${myArr[0]};
fi
/usr/bin/xrandr \
--output $dp1 --primary --scale 1.0 --mode 1920x1080 --rate 60 --pos 0x0 --rotate normal \
--output $dp2 --off \
--output eDP --off
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor$dp1/workspace0/last-image -s /home/fastix/Bilder/Wallpaper/papagei-gespiegelt.jpg
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor$dp2/workspace0/last-image -s /home/fastix/Bilder/Wallpaper/Papagei.jpg
fi
if [ $dontChangeAudio = "false" ]; then
hdmi_audio=$(wpctl status | grep 'Audio.*HDMI' | head -n1 | sed -E 's/^[^0-9]*([0-9]{1,3}).*$/\1/');
if [ -n "$hdmi_audio" ]; then
wpctl set-default $hdmi_audio
else
echo "Kein HDMI-Output gefunden. Wird also nicht aktiviert." 1>&2;
exit 2
fi
fi
if [ $noPresentationMode = "false" ]; then
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s true
fi