This script sets up a systemd service on Ubuntu Touch to grant the phablet
user access to key directories of the Android system inside the Waydroid container (such as Download
and Documents
).
This is enables you want to manage Waydroid's user files directly from the Ubuntu Touch file manager or terminal, and share files between the two systems.
- Adjusts folder permissions to make Waydroid’s shared storage readable/writable by the host.
- Creates a systemd service that waits for Waydroid to start, then applies the required permissions automatically.
- Creates a convenient symbolic link (
~/Waydroid
) in the phablet user's home directory for quick access.
-
~/.local/share/waydroid/data/media/0/
Download/
Music/
Documents/
DCIM/
To add more folders, update the chmod
commands in the CHMOD_CMD
variable in the script below
- On Ubuntu-Touch, in the terminal app, run the below shell script as the
phablet
user (or appropriate user with sudo access). - To allow your phablet user to write to the Android filesystem, you'll need to add the
phablet
user to the group that owns the Waydroid folder's contents, in my case this is group ID1023
:- mount your ubuntu touch filesystem as RW
- Create a group associated with the group ID of the owner of your Waydroid files, and add
phablet
to it:
sudo groupadd -g 1023 waydroid
sudo usermod -a -G waydroid phablet
- This assumes a standard installation path (
/home/phablet/.local/share/waydroid
). - Check that you're comfortable with the permissions applied using the
chmod
command - When opening the file-manager in Ubuntu-Touch, one must press the
Unlock
button in theRestricted access
banner and authenticate to view theWaydroid
symlink
## Waydroid Home-Folder Permission
# command to modify permissions to allow phablet user to read and write
# to Waydroid home folder subfolders
CHMOD_CMD="chmod ugo+rx /home/phablet/.local/share/waydroid/data/media/0/Documents/ && chmod ugo+rx /home/phablet/.local/share/waydroid/data/media/0/DCIM/ && chmod ugo+rx /home/phablet/.local/share/waydroid/data/media/0/Music/ && chmod ugo+rwx /home/phablet/.local/share/waydroid/data/media/0/Download/ && chmod ugo+rx /home/phablet/.local/share/waydroid/data/media/0/ && chmod ugo+rx /home/phablet/.local/share/waydroid/data/media/&& chmod ugo+rx /home/phablet/.local/share/waydroid/data/"
# create systemd service which applies permissions whenever Waydroid starts
echo $"[Unit]
Description=Give phablet user read-write permissions to waydroid's home folder.
After=waydroid-container
[Service]
ExecStart=/bin/bash -c 'while [ -z \"\$(waydroid status | grep RUNNING)\" ]; do sleep 1; done; sleep 20; $CHMOD_CMD'
[Install]
WantedBy=multi-user.target
" | sudo tee /etc/systemd/system/waydroid-permissions.service
sudo systemctl daemon-reload
sudo systemctl enable --now waydroid-permissions
# create symlink in Phablet's home folder pointing to the Waydroid home folder
ln -s /home/phablet/.local/share/waydroid/data/media/0/ ~/Waydroid