Fredrum / chiaki

Raspberry Pi fork of the Free and Open Source PS4 and PS5 Remote Play client Chiaki.
https://github.com/Fredrum/chiaki/wiki/rpi02---branch-for-Bullseye,-64bit,-h265-and-kmsdrm
GNU Affero General Public License v3.0
68 stars 11 forks source link

Start chiaki with a service #45

Closed AndSchroeder closed 1 year ago

AndSchroeder commented 1 year ago

Can you add an instruction on how to create a service or a way to start chiaki after startup of the pi?

Fredrum commented 1 year ago

I actually did this a few weeks ago for a little remote 'chiaki box' I gave my son to keep at his mum's so he can play on the PS5 when he's there too. I have a lot of 'real life' stuff I need to tend to in the near future so it might take some time. It's not hard to do though I'll see if I can find some links that were not to confusing to follow.

Fredrum commented 1 year ago

Actually its probably best if you just google it and try. I'm not going to have much time to do this and its sort of a separate thing. But please if you get a good solution post it here for others maybe?

brantai commented 1 year ago

I use the following .service file in my user-level systemd directory to start it:

[Unit]
Description=Chiaki
After=network.target

[Service]
ExecStart=/home/brantai/chiaki-rpi/build-release/rpi/chiaki-rpi 2>&1
Restart=always

[Install]
WantedBy=default.target

Replace the ExecStart with wherever you've built your chiaki-rpi binary.

Fredrum commented 1 year ago

I remember in my version I made a bash script instead of calling the executable straight from the service. I then added something like a 'sleep 3' in which allowed me to cancel out inbetween restarts if I needed to do some fixes. Otherwise I got stuck in a restart loop which was a bit tricky to break out of.

I also added another bash script to stop the service which I named a really short name like 'qq' so that I had time to type it in those three sleeping seconds.

Maybe there's a smarter way to handle that stuff than what I did?

AndSchroeder commented 1 year ago

Hey I was not able to start it with a service, but I found another approach. I created an autostart file to start a script in the gui.

first of all I created the bash script for starting chiaki directly in my home dir (start-chiaki.sh):

#! /bin/bash
sleep 5
chiaki-rpi/build/rpi/chiaki-rpi 2>&1

Additionally I added a gui autostart file

sudo nano /etc/xdg/autostart/psremote.desktop

After that I run the bash script to start chiaki

[Desktop Entry]
Exec=/home/username/start-chiaki.sh

Than i restarted with sudo reboot and chiaki started as well.

Now I only have to find a way to start it in desktop mode. Maybe another section in the wiki about autostart would be helpful.