add waydroid set gpu scripts to /usr/bin

This commit is contained in:
Anders Rytter Hansen 2025-10-07 17:14:31 -03:00
commit b52dd8d8ab
3 changed files with 87 additions and 0 deletions

View file

@ -33,6 +33,7 @@ RUN setsebool -P domain_kernel_load_modules on
COPY etc/environment /etc/environment
COPY etc/systemd/zram-generator.conf /etc/systemd/zram-generator.conf
COPY usr /usr
RUN cd /usr/bin && wget https://raw.githubusercontent.com/CachyOS/CachyOS-Settings/refs/heads/master/usr/bin/kerver && chmod +x kerver

38
usr/bin/waydroid-choose-gpu.sh Executable file
View file

@ -0,0 +1,38 @@
#!/bin/bash
lspci="$(lspci -nn | grep '\[03')" # https://pci-ids.ucw.cz/read/PD/03
echo -e "Please enter the GPU number you want to pass to WayDroid:\n"
gpus=()
i=0
while IFS= read lspci; do
gpus+=("$lspci")
echo " $((++i)). $lspci"
done < <(echo "$lspci")
echo ""
while [ -z "$gpuchoice" ]; do
read -erp ">> Number of GPU to pass to WayDroid (1-${#gpus[@]}): " ans
if [[ "$ans" =~ [0-9]+ && $ans -ge 1 && $ans -le ${#gpus[@]} ]]; then
gpuchoice="${gpus[$((ans-1))]%% *}" # e.g. "26:00.0"
fi
done
echo ""
echo "Confirm that these belong to your GPU:"
echo ""
ls -l /dev/dri/by-path/ | grep -i $gpuchoice
echo ""
card=$(ls -l /dev/dri/by-path/ | grep -i $gpuchoice | grep -o "card[0-9]")
rendernode=$(ls -l /dev/dri/by-path/ | grep -i $gpuchoice | grep -o "renderD[1-9][1-9][1-9]")
echo /dev/dri/$card
echo /dev/dri/$rendernode
cp /var/lib/waydroid/lxc/waydroid/config_nodes /var/lib/waydroid/lxc/waydroid/config_nodes.bak
#lxc.mount.entry = /dev/dri dev/dri none bind,create=dir,optional 0 0
sed -i '/dri/d' /var/lib/waydroid/lxc/waydroid/config_nodes
echo "lxc.mount.entry = /dev/dri/$card dev/dri/card0 none bind,create=file,optional 0 0" >> /var/lib/waydroid/lxc/waydroid/config_nodes
echo "lxc.mount.entry = /dev/dri/$rendernode dev/dri/renderD128 none bind,create=file,optional 0 0" >> /var/lib/waydroid/lxc/waydroid/config_nodes

View file

@ -0,0 +1,48 @@
#!/bin/bash
lspci="$(lspci -nn | grep '\[03')" # https://pci-ids.ucw.cz/read/PD/03
echo "Searching for Intel GPU..."
gpus=()
while IFS= read lspci; do
gpus+=("$lspci")
done < <(echo "$lspci")
# Automatically find and select Intel GPU
gpuchoice=""
for gpu in "${gpus[@]}"; do
if [[ "$gpu" == *"Intel"* ]]; then
gpuchoice="${gpu%% *}" # e.g. "26:00.0"
echo "Found Intel GPU: $gpu"
break
fi
done
if [ -z "$gpuchoice" ]; then
echo "Error: No Intel GPU found!"
echo "Available GPUs:"
for i in "${!gpus[@]}"; do
echo " $((i+1)). ${gpus[i]}"
done
exit 1
fi
echo ""
echo "Confirm that these belong to your GPU:"
echo ""
ls -l /dev/dri/by-path/ | grep -i $gpuchoice
echo ""
card=$(ls -l /dev/dri/by-path/ | grep -i $gpuchoice | grep -o "card[0-9]")
rendernode=$(ls -l /dev/dri/by-path/ | grep -i $gpuchoice | grep -o "renderD[1-9][1-9][1-9]")
echo /dev/dri/$card
echo /dev/dri/$rendernode
cp /var/lib/waydroid/lxc/waydroid/config_nodes /var/lib/waydroid/lxc/waydroid/config_nodes.bak
#lxc.mount.entry = /dev/dri dev/dri none bind,create=dir,optional 0 0
sed -i '/dri/d' /var/lib/waydroid/lxc/waydroid/config_nodes
echo "lxc.mount.entry = /dev/dri/$card dev/dri/card0 none bind,create=file,optional 0 0" >> /var/lib/waydroid/lxc/waydroid/config_nodes
echo "lxc.mount.entry = /dev/dri/$rendernode dev/dri/renderD128 none bind,create=file,optional 0 0" >> /var/lib/waydroid/lxc/waydroid/config_nodes