yavdr-ansible/roles/yavdr-desktop/templates/systemd/user/detect-second-display.service.j2
2018-09-24 22:56:36 +02:00

15 lines
499 B
Django/Jinja

[Unit]
Description=Detect second DISPLAY using xrandr
[Service]
Type=oneshot
ExecStart=/bin/bash -c '\
source <(systemctl --user show-environment); \
SECOND_DISPLAY="$${DISPLAY%\.[0-9]*}.1"; \
xrandr -d "$SECOND_DISPLAY" -q | grep "connected" && \
{ [ $DISPLAY == $SECOND_DISPLAY ] && echo "DISPLAY=$${DISPLAY%\.[0-9]*}.0 > ~/.second_display || echo "DISPLAY=$SECOND_DISPLAY" > ~/.second_display; \
} || rm -f ~/.second_display'
[Install]
WantedBy=yavdr-desktop.target