diff --git a/README.md b/README.md index e1a52de..a6f432a 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,6 @@ Another factor that may affect choice is the number of dependencies required to ### Arch Linux Arch Linux users can find a PKGBUILD in the [AUR](https://aur.archlinux.org/packages/kodi-standalone-service) that will take care of everything. Simply install and use. -### ARM distros -Users of ARM distros such as Arch ARM, Raspberry Pi OS (formerly Raspbian), etc. should NOT use these files since their official corresponding kodi packages supply their own version of a service. If you are knowledgeable enough with your distro, feel free to use/modify. - ### Ubuntu For the kodi user to access devices on `/dev/ttyxxxx`, users will need to edit `init/sysusers.conf` and uncomment the line corresponding to enable membership in the dialout group. diff --git a/arm/README.md b/arm/README.md new file mode 100644 index 0000000..cbe56b5 --- /dev/null +++ b/arm/README.md @@ -0,0 +1,3 @@ +# arm + +These files are used for Arch ARM's kodi packages only. diff --git a/arm/doc/kodi.service.1 b/arm/doc/kodi.service.1 new file mode 100644 index 0000000..cf0286e --- /dev/null +++ b/arm/doc/kodi.service.1 @@ -0,0 +1,46 @@ +.\" Text automatically generated by txt2man +.TH kodi.service 1 "13 March 2021" "" "" +.SH NAME +\fBkodi.service \fP- Systemd service unit to run Kodi in standalone mode without the need for a DE. +\fB +.SH DESCRIPTION + +.SH NOTES ON SYSTEM SHUTDOWN/REBOOT +Be aware that this service runs Kodi in systemd's user.slice not in the system.slice. In order to have Kodi gracefully exit, the system should be called to shutdown or to reboot using the respective Kodi actions not by a call to systemctl. +.PP +This is NOT recommended: +.PP +.nf +.fam C + # systemctl reboot + +.fam T +.fi +If you do reboot or shutdown via a call to systemctl, this will result in systemd killing the cg too quickly and data loss to your Kodi profile will occur. When Kodi exits cleanly, it will save GUI settings, media settings, Kodi uptime etc. In principal this is no different than data loss occurring from a user doing work when a sysadmin issues a reboot command without prior warning. While it is possible to run Kodi in systemd's system.slice instead, doing so makes it difficult to use USB mounts within Kodi and to use pulseaudio for Kodi sessions. +.SH RECOMMENDED METHODS TO SHUTDOWN/REBOOT +Here are several options: +.IP \(bu 3 +Select the corresponding option under Power menu in the Kodi GUI. +.IP \(bu 3 +Use the official Android/iOS remote app. +.IP \(bu 3 +If a CLI option is preferred, use kodi-send to issue the command to reboot or shutdown like so: +.PP +.nf +.fam C + $ kodi-send -a "Reboot" + $ kodi-send -a "ShutDown()" + +.fam T +.fi +Note that kodi-send is provided by the kodi-xxx-eventclients package where xxx is either, rpi, rpi-legacy, or git depending on which package group you installed. +.SH PASSING ENVIRONMENT VARIABLES TO THE SERVICE +Should the need arise, one can pass environment variables to the service by creating /etc/conf.d/kodi-standalone and populating it with the needed variables. +.SH CONTRIBUTE +Users wishing to contribute to this code, should fork and send a pull request. Source is freely available on the project page linked below. +.SH BUGS +Discover a bug? Please open an issue on the project page linked below. +.SH ONLINE +Project page: https://github.com/graysky2/kodi-standalone-service +.SH AUTHOR +graysky (graysky AT archlinux DOT us) diff --git a/arm/doc/manpage.txt b/arm/doc/manpage.txt new file mode 100644 index 0000000..7e050d3 --- /dev/null +++ b/arm/doc/manpage.txt @@ -0,0 +1,39 @@ +NAME +kodi.service - Systemd service unit to run Kodi in standalone mode without the need for a DE. + +DESCRIPTION + +NOTES ON SYSTEM SHUTDOWN/REBOOT +Be aware that this service runs Kodi in systemd's user.slice not in the system.slice. In order to have Kodi gracefully exit, the system should be called to shutdown or to reboot using the respective Kodi actions not by a call to systemctl. + +This is NOT recommended: + + # systemctl reboot + +If you do reboot or shutdown via a call to systemctl, this will result in systemd killing the cg too quickly and data loss to your Kodi profile will occur. When Kodi exits cleanly, it will save GUI settings, media settings, Kodi uptime etc. In principal this is no different than data loss occurring from a user doing work when a sysadmin issues a reboot command without prior warning. While it is possible to run Kodi in systemd's system.slice instead, doing so makes it difficult to use USB mounts within Kodi and to use pulseaudio for Kodi sessions. + +RECOMMENDED METHODS TO SHUTDOWN/REBOOT +Here are several options: +o Select the corresponding option under Power menu in the Kodi GUI. +o Use the official Android/iOS remote app. +o If a CLI option is preferred, use kodi-send to issue the command to reboot or shutdown like so: + + $ kodi-send -a "Reboot" + $ kodi-send -a "ShutDown()" + +Note that kodi-send is provided by the kodi-xxx-eventclients package where xxx is either, rpi, rpi-legacy, or git depending on which package group you installed. + +PASSING ENVIRONMENT VARIABLES TO THE SERVICE +Should the need arise, one can pass environment variables to the service by creating /etc/conf.d/kodi-standalone and populating it with the needed variables. + +CONTRIBUTE +Users wishing to contribute to this code, should fork and send a pull request. Source is freely available on the project page linked below. + +BUGS +Discover a bug? Please open an issue on the project page linked below. + +ONLINE +Project page: https://github.com/graysky2/kodi-standalone-service + +AUTHOR +graysky (graysky AT archlinux DOT us) diff --git a/arm/init/kodi.service b/arm/init/kodi.service new file mode 100644 index 0000000..d4fbe09 --- /dev/null +++ b/arm/init/kodi.service @@ -0,0 +1,21 @@ +[Unit] +Description=Kodi standalone (GBM) +After=remote-fs.target systemd-user-sessions.service network-online.target nss-lookup.target sound.target bluetooth.target polkit.service upower.service mysqld.service +Wants=network-online.target polkit.service upower.service +Conflicts=getty@tty1.service + +[Service] +User=kodi +Group=kodi +EnvironmentFile=-/etc/conf.d/kodi-standalone +PAMName=login +TTYPath=/dev/tty1 +Environment=WINDOWING=gbm +ExecStart=/usr/bin/kodi-standalone +ExecStop=/usr/bin/killall --user kodi --exact --wait kodi.bin +Restart=on-abort +StandardInput=tty +StandardOutput=journal + +[Install] +Alias=display-manager.service diff --git a/arm/init/sysusers.conf b/arm/init/sysusers.conf new file mode 100644 index 0000000..2498fe5 --- /dev/null +++ b/arm/init/sysusers.conf @@ -0,0 +1,16 @@ +# override these settings by copying this to /etc/sysusers.d/ and modifying it therein + +#Type Name ID GECOS Home directory Shell +g kodi - - +u kodi - "Kodi User" /var/lib/kodi + +# supplemental groups +m kodi audio +m kodi input +m kodi video +m kodi disk +m kodi network +m kodi optical +m kodi power +m kodi storage +m kodi tty diff --git a/arm/init/tmpfiles.conf b/arm/init/tmpfiles.conf new file mode 100644 index 0000000..a3d61ca --- /dev/null +++ b/arm/init/tmpfiles.conf @@ -0,0 +1,3 @@ +# Type Path Mode User Group Age Argument +d /var/lib/kodi 0750 kodi kodi - - +Z /var/lib/kodi - kodi kodi - - diff --git a/arm/polkit/polkit.rules b/arm/polkit/polkit.rules new file mode 100644 index 0000000..bcf7abf --- /dev/null +++ b/arm/polkit/polkit.rules @@ -0,0 +1,15 @@ +polkit.addRule(function(action, subject) { + if (subject.user == "kodi") { + polkit.log("action=" + action); + polkit.log("subject=" + subject); + if (action.id.indexOf("org.freedesktop.login1.") == 0) { + return polkit.Result.YES; + } + if (action.id.indexOf("org.freedesktop.udisks.") == 0) { + return polkit.Result.YES; + } + if (action.id.indexOf("org.freedesktop.udisks2.") == 0) { + return polkit.Result.YES; + } + } +}); diff --git a/arm/udev/99-kodi.rules b/arm/udev/99-kodi.rules new file mode 100644 index 0000000..0e54967 --- /dev/null +++ b/arm/udev/99-kodi.rules @@ -0,0 +1,5 @@ +SUBSYSTEM=="vc-sm",GROUP="video",MODE="0660" +SUBSYSTEM=="vchiq",GROUP="video",MODE="0660" +SUBSYSTEM=="tty", KERNEL=="tty[0-9]*", GROUP="tty", MODE="0660" +SUBSYSTEM=="dma_heap", KERNEL=="linux*", GROUP="video", MODE="0660" +SUBSYSTEM=="dma_heap", KERNEL=="system", GROUP="video", MODE="0660"