From 3b85e873c13f90ea40c48cc946e23d51fbcfb6fc Mon Sep 17 00:00:00 2001
From: j1nx
Date: Mon, 1 Jun 2020 15:41:14 +0200
Subject: [PATCH] MycroftOS: GUI: Launch mycroft-gui onto a weston wayland
compositor
---
.../mycroft-service/mycroft-gui.service | 6 +++-
.../mycroft-service/mycroft-service.mk | 8 ++++-
.../package/mycroft-service/weston.ini | 10 ++++++
.../package/mycroft-service/weston.service | 34 +++++++++++++++++++
.../system/mycroft.service.d/splash.conf | 2 +-
buildroot-external/user_table.txt | 2 +-
6 files changed, 58 insertions(+), 4 deletions(-)
create mode 100644 buildroot-external/package/mycroft-service/weston.ini
create mode 100644 buildroot-external/package/mycroft-service/weston.service
diff --git a/buildroot-external/package/mycroft-service/mycroft-gui.service b/buildroot-external/package/mycroft-service/mycroft-gui.service
index ebaad38a..7c09d42e 100644
--- a/buildroot-external/package/mycroft-service/mycroft-gui.service
+++ b/buildroot-external/package/mycroft-service/mycroft-gui.service
@@ -3,15 +3,19 @@ Description=Mycroft GUI
PartOf=mycroft.service
After=mycroft.service
After=mycroft-messagebus.service
+Wants=weston.service
+After=weston.service
[Service]
User=mycroft
WorkingDirectory=/home/mycroft
+Environment=QT_QPA_PLATFORM=wayland
+Environment=XDG_RUNTIME_DIR=/tmp/weston
Environment=LD_LIBRARY_PATH=/usr/lib
Environment=QML2_IMPORT_PATH=/usr/lib/qml
ExecStartPre=-/usr/bin/sudo /bin/psplash-write QUIT
ExecStart=mycroft-gui-app --hideTextInput --maximize
-StandardOutput=null
+StandardOutput=journal
Restart=on-failure
[Install]
diff --git a/buildroot-external/package/mycroft-service/mycroft-service.mk b/buildroot-external/package/mycroft-service/mycroft-service.mk
index 66f0b69a..3d01b8c6 100644
--- a/buildroot-external/package/mycroft-service/mycroft-service.mk
+++ b/buildroot-external/package/mycroft-service/mycroft-service.mk
@@ -23,8 +23,14 @@ define MYCROFT_SERVICE_INSTALL_TARGET_CMDS
$(TARGET_DIR)/usr/lib/systemd/system/mycroft-enclosure.service
$(INSTALL) -D -m 644 $(@D)/mycroft-skills.service \
$(TARGET_DIR)/usr/lib/systemd/system/mycroft-skills.service
- $(INSTALL) -D -m 644 $(@D)/mycroft-gui.service \
+ $(INSTALL) -D -m 644 $(@D)/mycroft-gui.service \
$(TARGET_DIR)/usr/lib/systemd/system/mycroft-gui.service
+ $(INSTALL) -D -m 644 $(@D)/weston.service \
+ $(TARGET_DIR)/usr/lib/systemd/system/weston.service
+
+ mkdir -p $(TARGET_DIR)/etc/xdg/weston
+ $(INSTALL) -D -m 644 $(@D)/weston.ini \
+ $(TARGET_DIR)/etc/xdg/weston/weston.ini
endef
$(eval $(generic-package))
diff --git a/buildroot-external/package/mycroft-service/weston.ini b/buildroot-external/package/mycroft-service/weston.ini
new file mode 100644
index 00000000..a67c5617
--- /dev/null
+++ b/buildroot-external/package/mycroft-service/weston.ini
@@ -0,0 +1,10 @@
+[core]
+idle-time=0
+require-input=false
+
+[shell]
+locking=false
+panel-location=""
+panel-position=""
+background-color=0xff000000
+panel-color=0xff000000
diff --git a/buildroot-external/package/mycroft-service/weston.service b/buildroot-external/package/mycroft-service/weston.service
new file mode 100644
index 00000000..9b666d48
--- /dev/null
+++ b/buildroot-external/package/mycroft-service/weston.service
@@ -0,0 +1,34 @@
+[Unit]
+Description=Weston, a Wayland compositor, as a system service
+Documentation=man:weston(1) man:weston.ini(5)
+Documentation=http://wayland.freedesktop.org/
+
+Wants=dbus.socket
+After=dbus.socket
+PartOf=mycroft.service
+After=mycroft.service
+
+ConditionPathExists=/dev/tty0
+
+[Service]
+Environment=XDG_RUNTIME_DIR=/tmp/weston
+Environment=XDG_CONFIG_HOME=/etc/xdg/weston
+ExecStartPre=-/usr/bin/mkdir /tmp/weston
+ExecStart=/usr/bin/weston-launch
+
+# A virtual terminal is needed.
+TTYPath=/dev/tty7
+TTYReset=yes
+TTYVHangup=yes
+TTYVTDisallocate=yes
+
+UtmpIdentifier=tty7
+UtmpMode=user
+
+User=mycroft
+
+# Fail to start if not controlling the tty.
+StandardInput=tty-fail
+
+[Install]
+WantedBy=multiuser.target
diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/mycroft.service.d/splash.conf b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/mycroft.service.d/splash.conf
index d0044e18..acf52d34 100644
--- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/mycroft.service.d/splash.conf
+++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/mycroft.service.d/splash.conf
@@ -1,2 +1,2 @@
[Service]
-ExecStartPre=-/bin/psplash-write "PROGRESS 80"
+ExecStartPre=-/usr/bin/sudo /bin/psplash-write "PROGRESS 80"
diff --git a/buildroot-external/user_table.txt b/buildroot-external/user_table.txt
index 270a3b1a..550edd85 100644
--- a/buildroot-external/user_table.txt
+++ b/buildroot-external/user_table.txt
@@ -1,2 +1,2 @@
-mycroft -1 mycroft -1 =mycroft /home/mycroft /bin/sh input,i2c,spi,gpio,audio,video,pulse,pulse-access,lp Mycroft user
+mycroft -1 mycroft -1 =mycroft /home/mycroft /bin/sh input,i2c,spi,gpio,audio,video,pulse,pulse-access,lp,weston-launch Mycroft user