Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
#!/usr/bin/env bash

# Check if the system is immutable and set directory variables.
if touch sudo /bin/testfile 2>/dev/null; then
# System is not immutable
sudo rm -f /bin/testfile
maindir="/usr"
bindir="/usr/bin"
libdir="/usr/lib"
sharedir="/usr/share"
applicationsdir="/usr/share/applications"
else
# System is immutable
maindir="$HOME/.local/"
bindir="$HOME/.local/bin"
libdir="$HOME/.local/lib"
sharedir="$HOME/.local/share"
applicationsdir="$HOME/.local/share/applications"
fi

# Check if script is from cloned repo or just coppied from github
if [ -n "$(git config --get remote.origin.url)" ]; then
echo ""
echo
echo "Cloned repo"
CLONED=true
else
echo ""
echo
echo "Copied from github"
TEMPDIR=`mktemp -d`
CLONED=false
Expand All @@ -19,16 +37,16 @@ if [ "$CLONED" = false ]; then
cd $TEMPDIR
fi

echo ""
echo
echo "Installing..."
sudo cp -r usr/* /usr/
sudo chmod +x /usr/bin/waydroid-settings
sudo chmod +x /usr/bin/waydroid-helper
sudo update-desktop-database /usr/share/applications
sudo update-icon-caches /usr/share/icons/hicolor
sudo cp -r usr/* $maindir #what does this do
sudo chmod +x $bindir/waydroid-settings
sudo chmod +x $bindir/waydroid-helper
sudo update-desktop-database $applicationsdir
sudo update-icon-caches $maindir/icons/hicolor

# if scripts/* exist, then copy those to ~/.local/share/waydroid-settings
echo ""
echo
echo "Copying scripts to ~/.local/share/waydroid-settings"

if [ -n "$(find scripts -maxdepth 1 -type f)" ]; then
Expand All @@ -45,7 +63,7 @@ fi

# if CLONEED == false, then cleanup ~/.local/share/waydroid-settings
if [ "$CLONED" = false ]; then
echo ""
echo
echo "Cleaning up"
rm -rf $TEMPDIR
fi
fi
28 changes: 22 additions & 6 deletions uninstall.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
#!/usr/bin/env bash

# Check if the system is immutable and set directory variables.
if sudo touch /bin/testfile 2>/dev/null; then
# System is not immutable
sudo rm -f /bin/testfile
bindir="/usr/bin"
sharedir="/usr/share"
applicationsdir="/usr/share/applications"
polkitdir="/usr/share/polkit-1"
else
# System is immutable
bindir="$HOME/.local/bin"
sharedir="$HOME/.local/share"
applicationsdir="$HOME/.local/share/applications"
polkitdir="/etc/polkit-1/"
fi

sudo rm -rf $HOME/.local/share/waydroid-settings /usr/share/waydroid-settings /usr/lib/waydroid-settings
sudo rm -f /usr/bin/waydroid-settings
sudo rm -f /usr/bin/waydroid-helper
sudo rm -f /usr/share/applications/waydroid-settings.desktop
sudo rm -f /usr/share/applications/install-to-waydroid.desktop
sudo rm -f /usr/share/icons/hicolor/512x512/apps/cu.axel.WaydroidSettings.png
sudo rm -f /usr/share/polkit-1/actions/org.freedesktop.policykit.waydroid-helper.policy
sudo rm -f $bindir/waydroid-settings
sudo rm -f $bindir/waydroid-helper
sudo rm -f $applicationsdir/waydroid-settings.desktop
sudo rm -f $applicationsdir/install-to-waydroid.desktop
sudo rm -f $sharedir/icons/hicolor/512x512/apps/cu.axel.WaydroidSettings.png
sudo rm -f $polkitdir/actions/org.freedesktop.policykit.waydroid-helper.policy

echo "Waydroid Settings has been uninstalled"
12 changes: 11 additions & 1 deletion usr/bin/waydroid-settings
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
#!/usr/bin/env bash
/usr/lib/waydroid-settings/waydroid-settings.py "$@"

# Check if the system is immutable and set directory variables.
if sudo touch /bin/testfile 2>/dev/null; then
# System is not immutable
libdir="/usr/lib"
else
# System is immutable
libdir="$HOME/.local/lib"
fi

$libdir/waydroid-settings/waydroid-settings.py "$@"
28 changes: 25 additions & 3 deletions usr/lib/waydroid-settings/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,28 @@
from pathlib import Path
from gi.repository import GLib

# Function to check if a directory is writable
def is_writable(directory):
try:
with open(os.path.join(directory, 'testfile'), 'w'):
pass
os.remove(os.path.join(directory, 'testfile'))
return True
except IOError:
return False

# Check if the system is immutable
if is_writable('/bin'):
# System is not immutable
bindir = "/usr/bin"
libdir = "/usr/lib"
sharedir = "/usr/share"
else:
# System is immutable
bindir = os.path.expanduser("~/.local/bin")
libdir = os.path.expanduser("~/.local/lib")
sharedir = os.path.expanduser("~/.local/share")

PROP_FREE_FORM = 'persist.waydroid.multi_windows'
PROP_INVERT_COLORS = ''
PROP_SUSPEND_INACTIVE = 'persist.waydroid.suspend'
Expand All @@ -20,7 +42,7 @@

# System.img paths
SYSTEM_IMAGE1 = '/var/lib/waydroid/images/system.img'
SYSTEM_IMAGE2 = '/usr/share/waydroid-extra/images/system.img'
SYSTEM_IMAGE2 = '{sharedir}/waydroid-extra/images/system.img'

# Check whether the specified path exists
# Depending on install type, this might change
Expand All @@ -37,7 +59,7 @@
def run(command, as_root=False):
try:
if as_root:
subprocess.run(['pkexec', '/usr/bin/waydroid-helper', command])
subprocess.run(['pkexec', '{bindir}/waydroid-helper', command])
else:
subprocess.run(command, shell=True)
return True
Expand Down Expand Up @@ -68,7 +90,7 @@ def set_prop(name, value):
def run_shell_command(command, as_root=False):
try:
if as_root:
subprocess.run('pkexec /usr/bin/waydroid-helper ' + '" | echo "' + command + '" | sudo -S waydroid shell"', text=True)
subprocess.run('pkexec {bindir}/waydroid-helper ' + '" | echo "' + command + '" | sudo -S waydroid shell"', text=True)
else:
subprocess.run(command, shell=True)
return True
Expand Down
2 changes: 1 addition & 1 deletion usr/share/applications/install-to-waydroid.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Icon=cu.axel.WaydroidSettings
Type=Application
Name=Install to Waydroid
Exec=sudo waydroid app install %F
Exec=waydroid app install %F
MimeType=application/vnd.android.package-archive
Terminal=true
NoDisplay=true
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<allow_active>auth_admin_keep</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/waydroid-helper</annotate>
<annotate key="org.freedesktop.policykit.exec.path">$HOME/.local/bin/waydroid-helper</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig>