[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