feat(waydroid): Add script to fix controllers in Waydroid

This commit is contained in:
Kyle Gospodnetich 2023-10-02 21:04:40 -07:00
parent afd20b67e6
commit 2792919ca9
4 changed files with 29 additions and 2 deletions

View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
sudo sh -c 'for i in $(seq 7 9); do echo add > /sys/class/input/event$i/uevent; done'

View File

@ -2,23 +2,35 @@
source /etc/default/waydroid-launcher
# Kill any previous remnants
if [ "$(systemctl is-active waydroid-container.service)" == 'active' ]; then
killall -9 weston
pkexec /usr/bin/waydroid-container-stop
exit
fi
# Launch Weston
killall -9 weston
pkexec /usr/bin/waydroid-container-start
if [ -z "$(pgrep weston)" ]; then
/usr/bin/weston --socket=weston-waydroid --width=${WAYDROID_WIDTH} --height=${WAYDROID_HEIGHT} &> /dev/null &
fi
# Launch Waydroid
sleep 2 &&
export XDG_SESSION_TYPE='wayland'
export WAYLAND_DISPLAY='weston-waydroid'
/usr/bin/waydroid $@ &
while [ -n "$(pgrep weston)" ];do
# Fix controllers, we know Waydroid has started because surfaceflinger is running
while [ "" == "$(pgrep surfaceflinger)" ]; do
sleep 1
done
pkexec /usr/bin/waydroid-fix-controllers
# Waydroid is now live!
# Wait for exit and then clean up
while [ -n "$(pgrep weston)" ]; do
sleep 1
done

View File

@ -29,3 +29,14 @@
</action>
</policyconfig>
<action id="org.bazzite.policykit.waydroid.fix.controllers">
<description>Fix Controllers in Waydroid</description>
<icon_name>package-x-generic</icon_name>
<defaults>
<allow_any>yes</allow_any>
<allow_inactive>yes</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/waydroid-fix-controllers</annotate>
</action>
</policyconfig>

View File

@ -1,6 +1,7 @@
polkit.addRule(function(action, subject) {
if ((action.id == "org.bazzite.policykit.waydroid.container.start" ||
action.id == "org.bazzite.policykit.waydroid.container.stop") &&
action.id == "org.bazzite.policykit.waydroid.container.stop" ||
action.id == "org.bazzite.policykit.waydroid.fix.controllers") &&
subject.isInGroup("wheel")) {
return polkit.Result.YES;
}