@@ -108,22 +108,46 @@ remove_splashscreen() {
108108 fi
109109}
110110
111- create_autostart_file () {
112- autostart_path=" /etc/xdg/autostart/retroi.desktop"
113-
114- sudo tee " $autostart_path " > /dev/null << EOF
115- [Desktop Entry]
116- Name=Retro.I
117- Type=Application
118- Exec=sh -c '$RETROI_DIR /scripts/start.sh >> $HOME /autostart.log 2>&1'
119- Terminal=true
111+ apply_audio_group () {
112+ sudo usermod -aG audio $USER
113+ }
114+
115+ create_systemd_service () {
116+ systemd_path=" /etc/systemd/system/retroi.service"
117+
118+ user_id=$( id -u)
119+
120+ sudo tee " $systemd_path " > /dev/null << EOF
121+ [Unit]
122+ Description=Retro.I Desktop App
123+ After=graphical.target
124+
125+ [Service]
126+ Type=simple
127+ User=pi
128+ Group=pi
129+ WorkingDirectory=$RETROI_DIR
130+ ExecStart=$RETROI_DIR /.venv/bin/python $RETROI_DIR /main.py
131+ Restart=no
132+ Environment=DISPLAY=:0
133+ Environment=XAUTHORITY=/home/pi/.Xauthority
134+ Environment=XDG_RUNTIME_DIR=/run/user/$user_id
135+ Environment=PULSE_SERVER=unix:/run/user/$user_id /pulse/native
136+ TimeoutStopSec=1
137+ KillSignal=SIGKILL
138+ KillMode=control-group
139+
140+ [Install]
141+ WantedBy=graphical.target
120142EOF
121143
122144 # Verify creation
123- if ! grep -q -- " ^\[Desktop Entry \]" " $autostart_path " ; then
124- echo " Autostart file could not be created correctly!" >&2
145+ if ! grep -q -- " ^\[Service \]" " $systemd_path " ; then
146+ echo " Systemd file could not be created correctly!" >&2
125147 return 1
126148 fi
149+
150+ sudo systemctl enable retroi.service
127151}
128152
129153hide_taskbar () {
147171remove_background_image () {
148172 pcmanfm --set-wallpaper " " --wallpaper-mode=color
149173
174+ mkdir -p " $HOME /.config/pcmanfm"
175+
176+ pcmanfm --reconfigure
177+ sleep 0.5
178+
150179 CONFIG_FILES=$( find " $HOME /.config/pcmanfm" -type f -name " desktop-items-*.conf" 2> /dev/null)
151180
152181 if [ -z " $CONFIG_FILES " ]; then
@@ -374,7 +403,8 @@ read -p "Drücke <ENTER> um das Setup zu beginnen..."
374403set_project_path
375404run_step " Entferne Splashscreen" remove_splashscreen
376405run_step " System-Splashscreen ändern" sudo -E bash -c " $RETROI_DIR /update-system-splash.sh"
377- run_step " Erstelle Autostart-Datei" create_autostart_file
406+ run_step " User zur \" audio\" Gruppe hinzufügen" apply_audio_group
407+ run_step " Systemd-Datei für Systemstart erstellen" create_systemd_service
378408run_step " Taskbar ausblenden" hide_taskbar
379409run_step " Hintergrund entfernen" remove_background_image
380410run_step " Mülleimer entfernen" remove_trash_basket
0 commit comments