Skip to content

Commit

Permalink
feat(waydroid): Add script to fix controllers in Waydroid
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleGospo committed Oct 3, 2023
1 parent afd20b6 commit 2792919
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
3 changes: 3 additions & 0 deletions system_files/desktop/shared/usr/bin/waydroid-fix-controllers
Original file line number Diff line number Diff line change
@@ -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'
14 changes: 13 additions & 1 deletion system_files/desktop/shared/usr/bin/waydroid-launcher
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down

0 comments on commit 2792919

Please sign in to comment.