yavdr-ansible/roles/yavdr-desktop/templates/bin/detect-second-display.j2
2018-09-30 10:17:20 +02:00

10 lines
323 B
Django/Jinja

#!/bin/bash
source <(systemctl --user show-environment)
SECOND_DISPLAY="${DISPLAY%\.[0-9]*}.1"
if xrandr -d "$SECOND_DISPLAY" -q | grep -q "connected"; then
[ "$DISPLAY" != "$SECOND_DISPLAY" ] && d="DISPLAY=$SECOND_DISPLAY" || d="DISPLAY=$DISPLAY"
echo "$d" > ~/.second_display;
else
rm -f ~/.second_display
fi