Novice Linux user here. I used a bit of ChatGPT to write this. I’d like to know if it would be sufficient enough to use. I think most of the script is pretty self-explanatory, aside from the creation of the 99-vc4.conf
file so I’ll explain that real quick…
I ran into an issue with x-org and the Raspberry Pi 5. The solution was adding the file you see below. The details are in this post here.
I think that it would be best this all ran post DietPi automation?
#!/bin/bash
# Enable 4K in config.txt
echo "enable_hdmi_4kp60=1" | sudo tee -a /boot/config.txt
# Create 99-vc4.conf for 4K support
FILE="/etc/X11/xorg.conf.d/99-vc4.conf"
CONTENT='Section "OutputClass"
Identifier "vc4"
MatchDriver "vc4"
Driver "modesetting"
Option "PrimaryGPU" "true"
EndSection'
echo "${CONTENT}" | sudo tee ${FILE}
# Create x0vncserver start script in /home/dietpi/
FILE="/home/dietpi/x0vnc.sh"
CONTENT='#! /bin/bash
# Export an environment variable of the Display Manager
export DISPLAY=:0
export XAUTHORITY="/home/dietpi/.Xauthority"
# Start VNC server for :0 display in background
## Set path to binary file
VNC_BIN=/usr/bin/x0vncserver
## Set parameters
PARAMS="-passwordfile ~/.vnc/passwd -display $DISPLAY -SecurityTypes tlsplain"
## Launch VNC server
($VNC_BIN $PARAMS)
# Provide dirty exit code so that systemd
# will restart the server when a user logs out
exit 1'
echo "${CONTENT}" | sudo tee ${FILE}
sudo chmod +x ${FILE}
# Add /home/dietpi/x0vnc.sh to .bashrc for automatic execution at login
echo "${FILE}" | sudo tee -a /home/dietpi/.bashrc
# Disable boot messages
FILE="/boot/cmdline.txt"
sudo sed -i 's/console=tty1/console=tty3/' ${FILE}
sudo sed -i 's/$/ vt.global_cursor_default=0 quiet loglevel=0 splash/' ${FILE}
# Disable cursor in Chromium
FILE="/var/lib/dietpi/dietpi-software/installed/chromium-autostart.sh"
sudo sed -i '$ s/$/ -- -nocursor/' ${FILE}
# Install uhubctl (control USB ports)
sudo apt install -y uhubctl
# Add uhubctl commands to bashrc to disable USB ports after login
FILE="/home/dietpi/.bashrc"
CONTENT='sudo uhubctl -l 1 -a 0 && uhubctl -l 3 -a 0'
echo "${CONTENT}" | sudo tee -a ${FILE}
# END
echo "Script complete...Rebooting now"
sudo reboot now