viktorgino / headunit-desktop

HeadUnit Desktop is a car PC software built with Qt 5 and QML
https://github.com/viktorgino/headunit-desktop/wiki
GNU General Public License v3.0
284 stars 64 forks source link

[question] any way to auto start? #26

Closed DavMon closed 6 years ago

DavMon commented 6 years ago

Is there any way to auto start this instead of having to always login and use QT_QPA_PLATFORM=eglfs /opt/headunit-desktop/headunit-app as I'd rather not have to carry a keyboard in my car

viktorgino commented 6 years ago

Yes, there is. I'll add this to the new image, but the steps are:

Create a new service file in /lib/systemd/system/ :

sudo nano /lib/systemd/system/headunit.service

Paste the following into the file:

[Unit]
Description=Viktorgino's Headunit Desktop Service
After=multi-user.target

[Service]
Type=idle
User=pi
Group=pi
Environment="QT_QPA_PLATFORM=eglfs"
ExecStart=/opt/headunit-desktop/headunit-app
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

Modify the permissions on the new service file:

sudo chmod 644 /lib/systemd/system/headunit.service

Enable it with systemd:

sudo systemctl daemon-reload
sudo systemctl enable sample.service

And reboot:

sudo reboot 0
DavMon commented 6 years ago

Thank you will do this