yavdr-ansible/roles/yavdr-desktop/templates/systemd/user/detect-second-display.service.j2

15 lines
499 B
Plaintext
Raw Normal View History

2017-06-21 10:14:35 +02:00
[Unit]
Description=Detect second DISPLAY using xrandr
[Service]
Type=oneshot
2018-09-24 22:56:36 +02:00
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'
2017-06-21 10:14:35 +02:00
[Install]
WantedBy=yavdr-desktop.target