Improve switching primary and secondary display
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
- '{{ vdr.home }}/.config/systemd/user'
|
||||
- '{{ vdr.home }}/.config/openbox'
|
||||
- '{{ vdr.home }}/.config/pulse'
|
||||
- '{{ vdr.home }}/bin'
|
||||
|
||||
- name: expand template for .xinitrc for vdr user
|
||||
template:
|
||||
@@ -94,6 +95,14 @@
|
||||
owner: '{{ vdr.user }}'
|
||||
group: '{{ vdr.group }}'
|
||||
|
||||
- name: create detect-second-diplay script
|
||||
template:
|
||||
src: templates/bin/detect-second-display.j2
|
||||
dest: '{{ vdr.home }}/bin/detect-second-display'
|
||||
mode: 0755
|
||||
owner: '{{ vdr.user }}'
|
||||
group: '{{ vdr.group }}'
|
||||
|
||||
- name: create openbox-second.service for the session
|
||||
template:
|
||||
src: templates/systemd/user/openbox-second.service.j2
|
||||
|
@@ -0,0 +1,9 @@
|
||||
#!/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
|
@@ -3,7 +3,7 @@ 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=%h/bin/detect-second-display
|
||||
|
||||
[Install]
|
||||
WantedBy=yavdr-desktop.target
|
||||
|
Reference in New Issue
Block a user