Fix detect-second-display.service

This commit is contained in:
Alexander Grothe 2018-09-24 22:56:36 +02:00
parent 47061871ed
commit 8fbc3f08a5
2 changed files with 12 additions and 2 deletions

View File

@ -4353,7 +4353,12 @@ Description=Detect second DISPLAY using xrandr
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'export DISPLAY=$DISPLAY.1; xrandr -q | grep "connected" && echo "DISPLAY=$DISPLAY" > ~/.second_display || rm -f ~/.second_display'
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

View File

@ -3,7 +3,12 @@ Description=Detect second DISPLAY using xrandr
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'export DISPLAY=$DISPLAY.1; xrandr -q | grep "connected" && echo "DISPLAY=$DISPLAY" > ~/.second_display || rm -f ~/.second_display'
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