Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ansible/video] Detect WAYLAND_DISPLAY and dynamic DISPLAY #126

Merged
merged 7 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ansible/roles/ovos_installer/tasks/docker/composer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
tags:
- always

- name: Remove DISPLAY variable if EGLFS is used
- name: Remove DISPLAY and WAYLAND_DISPLAY variables if EGLFS is used
ansible.builtin.lineinfile:
path: "{{ _composition_directory }}/docker-compose.gui.yml"
search_string: "DISPLAY"
Expand Down
34 changes: 34 additions & 0 deletions ansible/roles/ovos_installer/tasks/video.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,37 @@
group: "{{ ovos_installer_group }}"
mode: "0600"
when: "'Raspberry Pi 5' in ovos_installer_raspberrypi and ovos_installer_display_server == 'N/A'"

- name: Block DISPLAY server & Wayland socket
when: ovos_installer_display_server != "N/A"
block:
# The find module doesn't support the socket type and it could generate a
# "permission denied" error depending the content of /run/user/UID
- name: Check for wayland socket
ansible.builtin.shell:
cmd: |
set -e -o pipefail
ls -1 /run/user/{{ ovos_installer_uid }} | grep -E '^wayland-[0-9]$'
executable: /bin/bash
register: _ovos_wayland_display
changed_when: false
when: ovos_installer_display_server == 'wayland'

- name: Set ovos_installer_wayland_display fact
ansible.builtin.set_fact:
ovos_installer_wayland_display: "{{ _ovos_wayland_display.stdout }}"
when: _ovos_wayland_display is defined and _ovos_wayland_display.stdout | length > 0

- name: Detect DISPLAY server number
ansible.builtin.shell:
cmd: |
set -e -o pipefail
sed -zn 's/^DISPLAY=//p' /proc/*/environ | sort -zu | tr '\0' '\n'
executable: /bin/bash
register: _ovos_display_server_number
changed_when: false

- name: Set ovos_installer_display_server_number fact
ansible.builtin.set_fact:
ovos_installer_display_server_number: "{{ _ovos_display_server_number.stdout }}"
when: _ovos_display_server_number.stdout | length > 0
5 changes: 4 additions & 1 deletion ansible/roles/ovos_installer/templates/docker/env.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#jinja2: lstrip_blocks: True
{% if ovos_installer_display_server != 'N/A' %}
DISPLAY=:0
DISPLAY={{ ovos_installer_display_server_number if ovos_installer_display_server_number is defined else ':0' }}
{% endif %}
{% if 'gpio' in getent_group %}
GPIO_GID={{ getent_group['gpio'][1] }}
Expand Down Expand Up @@ -53,4 +53,7 @@ VOICE_SAT_PASSWORD={{ ovos_installer_satellite_password }}
VOICE_SAT_HOST=ws://{{ ovos_installer_listener_host }}
VOICE_SAT_PORT={{ ovos_installer_listener_port | default(5678) }}
{% endif %}
{% if ovos_installer_display_server != 'N/A' %}
WAYLAND_DISPLAY={{ ovos_installer_wayland_display if ovos_installer_wayland_display is defined else 'wayland-0' }}
{% endif %}
XDG_RUNTIME_DIR=/run/user/{{ ovos_installer_uid }}
Loading