@@ -22,6 +22,24 @@ _check_kernel() (
2222 fi
2323)
2424
25+ _sudo_run() {
26+ if _is_cmd pkexec; then
27+ sudocmd=pkexec
28+ elif _is_cmd lxqt-sudo; then
29+ sudocmd=lxqt-sudo
30+ elif [ -t 0 ]; then
31+ if _is_cmd sudo; then sudocmd=sudo
32+ elif _is_cmd doas; then sudocmd=doas
33+ else >&2 echo "ERROR: We need sudo or doas to start Waydroid!"; exit 1
34+ fi
35+ else
36+ zenity --error --text "We need 'pkexec' or 'lxqt-sudo' to setup Waydroid"
37+ zenity --info --text "Launch the AppImage from the terminal so we can prompt sudo/doas instead"
38+ exit 1
39+ fi
40+ "$sudocmd" "$@"
41+ }
42+
2543_install_polkit_policy() (
2644 rule_src="$APPDIR"/share/polkit-1/actions/id.waydro.Container.policy
2745 rule_dst=/usr/share/polkit-1/actions/id.waydro.Container.policy
@@ -47,7 +65,7 @@ _install_polkit_policy() (
4765 In that case you will have to remove those files manually!
4866 EOF
4967 )" || return 1
50- $sudocmd /bin/sh -c "
68+ _sudo_run /bin/sh -c "
5169 mkdir -p /usr/share/polkit-1/actions
5270 mkdir -p /usr/share/dbus-1/system-services
5371 mkdir -p /usr/share/dbus-1/system.d
@@ -84,7 +102,7 @@ _is_session_running() {
84102
85103_start_waydroid() {
86104 if ! _is_container_running; then
87- $sudocmd "$APPDIR"/bin/python3 "$APPDIR"/bin/waydroid container start &
105+ _sudo_run "$APPDIR"/bin/python3 "$APPDIR"/bin/waydroid container start &
88106 fi
89107 # now we need to wait for the container to start
90108 count=0
@@ -111,17 +129,6 @@ _start_waydroid() {
111129 fi
112130}
113131
114- if _is_cmd pkexec; then
115- sudocmd=pkexec
116- elif _is_cmd lxqt-sudo; then
117- sudocmd=lxqt-sudo
118- elif [ "$(id -u)" = 0 ]; then
119- sudocmd=""
120- else
121- zenity --error --text "We need 'pkexec' or 'lxqt-sudo' to setup Waydroid"
122- exit 1
123- fi
124-
125132_check_kernel
126133_install_polkit_policy || :
127134_start_12to11
0 commit comments