From 7a6085e7df39b536849260d990807d6772f91696 Mon Sep 17 00:00:00 2001 From: Kyle Gospodnetich Date: Sun, 1 Oct 2023 15:57:19 -0700 Subject: [PATCH] feat: Add Weston launcher for Waydroid using policykit to start and stop service --- .../shared/usr/bin/waydroid-container-start | 3 ++ .../shared/usr/bin/waydroid-container-stop | 3 ++ .../desktop/shared/usr/bin/waydroid-launcher | 25 +++++++++++++++ .../shared/usr/etc/default/waydroid-launcher | 2 ++ .../share/polkit-1/actions/org.bazzite.policy | 31 +++++++++++++++++++ 5 files changed, 64 insertions(+) create mode 100644 system_files/desktop/shared/usr/bin/waydroid-container-start create mode 100644 system_files/desktop/shared/usr/bin/waydroid-container-stop create mode 100644 system_files/desktop/shared/usr/bin/waydroid-launcher create mode 100644 system_files/desktop/shared/usr/etc/default/waydroid-launcher create mode 100644 system_files/desktop/shared/usr/share/polkit-1/actions/org.bazzite.policy diff --git a/system_files/desktop/shared/usr/bin/waydroid-container-start b/system_files/desktop/shared/usr/bin/waydroid-container-start new file mode 100644 index 00000000..0beb3f03 --- /dev/null +++ b/system_files/desktop/shared/usr/bin/waydroid-container-start @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +sudo systemctl start waydroid-container.service diff --git a/system_files/desktop/shared/usr/bin/waydroid-container-stop b/system_files/desktop/shared/usr/bin/waydroid-container-stop new file mode 100644 index 00000000..9cbd09a7 --- /dev/null +++ b/system_files/desktop/shared/usr/bin/waydroid-container-stop @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +sudo systemctl stop waydroid-container.service diff --git a/system_files/desktop/shared/usr/bin/waydroid-launcher b/system_files/desktop/shared/usr/bin/waydroid-launcher new file mode 100644 index 00000000..3f25790f --- /dev/null +++ b/system_files/desktop/shared/usr/bin/waydroid-launcher @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +source /etc/default/waydroid-launcher + +if [ "$(systemctl is-active waydroid-container.service)" == 'active' ]; then + killall -9 weston + pkexec /usr/bin/stop-waydroid-container + exit +fi + +killall -9 weston +pkexec /usr/bin/start-waydroid-container +if [ -z "$(pgrep weston)" ]; then + /usr/bin/weston --xwayland --width="${WAYDROID_WIDTH}" --height="${WAYDROID_HEIGHT}" &> /dev/null & +fi + +sleep 2 && +export XDG_SESSION_TYPE='wayland' +export DISPLAY=':1' +/usr/bin/waydroid show-full-ui & +while [ -n "$(pgrep weston)" ];do + sleep 1 +done + +pkexec /usr/bin/stop-waydroid-container diff --git a/system_files/desktop/shared/usr/etc/default/waydroid-launcher b/system_files/desktop/shared/usr/etc/default/waydroid-launcher new file mode 100644 index 00000000..0a8e0f3e --- /dev/null +++ b/system_files/desktop/shared/usr/etc/default/waydroid-launcher @@ -0,0 +1,2 @@ +WAYDROID_WIDTH=1280 +WAYDROID_HEIGHT=800 diff --git a/system_files/desktop/shared/usr/share/polkit-1/actions/org.bazzite.policy b/system_files/desktop/shared/usr/share/polkit-1/actions/org.bazzite.policy new file mode 100644 index 00000000..d955e48a --- /dev/null +++ b/system_files/desktop/shared/usr/share/polkit-1/actions/org.bazzite.policy @@ -0,0 +1,31 @@ + + + + Bazzite + https://bazzite.gg + + + Start Waydroid Container + package-x-generic + + yes + yes + yes + + /usr/bin/waydroid-container-start + + + + Stop Waydroid Container + package-x-generic + + yes + yes + yes + + /usr/bin/waydroid-container-stop + + +