Vdr backend and Kodi frontend in same machine

  • Hi to everyone from finland! 8)

    I, and my wife too, have been happy Vdr user for 13years and Kodi even longer, but usually on separate computers. My old PVR setup (based on yavdr and before that I compiled everything from scratch) worked just fine for many years without problems. Now its motherboard came to end of the road and I had to find replacement with reasonable "wife acceptance factor".

    I remembered that I had old Zotac Ion mainboard and some small itx case and started to build PVR from scratch on top of that.

    I installed Lubuntu 18.04 and configured it boot to plain Openbox. Installed latest Kodi Leia. Then made simple autostart file which starts Kodi. So this is okay..

    Next I installed Vdr with few plugins yavdr experimental repo.

    1. vdr                                            2.4.0-42yavdr0~bionic
    2. vdr-addon-acpiwakeup        0.0.10-11yavdr0~bionic
    3. vdr-addon-lifeguard              0.0.4-5yavdr1~bionic
    4. vdr-plugin-epgsearch            2.4.0+git20190919-8-84811de-0yavdr0~bionic
    5. vdr-plugin-live                        2.3.1+git20170623.4.6335b64-4yavdr0~bionic
    6. vdr-plugin-vdrmanager        0.14.git20191010-26-3a8b944-1yavdr0~bionic
    7. vdr-plugin-vnsiserver            2:1.8.0+git20191125-2-ce9f23d-0yavdr0~bionic

    And for kodi:

    1. kodi-pvr-vdr-vnsi                     3.6.3-1~bionic

    Okay, everything works now quite well. We can watch live tv from Kodi, recordings works, I even got that old hdd mounted to Kodi so my wife can watch her old recorded tv series and movies..

    Acpi wakeup also works good.

    My wife is now quite happy with it, she can make automatic epg search timers from Live and her Sailfish phone also has vdr-manager android app installed.. So, setting timers and managing recordings is easy for her.

    Then it comes a bit complicated for me. Because of kodi is being frontend and it boots always straight to it, vdr cannot shutdown itself when it wants. So, I configured Kodi to quit desktop after 1hour inactivity and vdr side is set to shut after 10min. Now vdr can shut itself down after reasonable amount of time. But solution aint pretty and I want it better if possible..

    I managed to get shutdown working when user klicks "shutdown" from Kodi menu, then small script is executed and kodi exits to desktop and then "svdrpsend hitk power" shuts vdr and sets wakeup time if necessary.

    Lifeguard plugin checks ssh connection and if there is apt running when shutdown.

    But some script magic is still needed, which is far too difficult for me. If someone have been using this kind of setup and have script examples how to proceed, I would be very thankful.

    What is missing from my setup:

    1. I want that when user clicks shutdown from kodi menu > vdr checks if there are any upcoming timers or ssh connections preventing shutdown and reports to Kodi and it shows to user a message. If there arent any > then vdr shuts computer and sets wakeup time.

    2. I also want to get that same behavior for user inactivity. Eg. After 1hour inactivity in Kodi > vdr check upcoming timers etc. and shuts everything down properly and sets wakeup time.

    3. How do I change case power button behavior? Now it try to suspend computer and because of it, it doesnt set wakeup time. I want it to run same script as above, so everything is checked and wakeup set before shutdown.

    4. I have Logitech k400r keyboard and there is also power button. Is it possible to get same behavior to it also, so if user presses button, same script is executed and again everything is checked?

    Sorry for long post and my bad english. I hope you get an idea what I mean.. Thanks!

    Best regards!

  • I am using this addon for koidi https://github.com/Paulemann/service.shutdown.watchdog which should address most or at least some of your requirements.

    In kodi you must configure a keymaps.xml (or any other .xml) file in userdata/keymaps with the code of k400r power button to trigger the script.

    I am not yet sure why you're taking all the effort to have vdr shutdown separately. I just shutdown from kodi and that's all it needs.

    You can configure wakeup timer via a small exceutable script setwakeup.sh you put e.g. in /usr/local/bin and which is specified under kodi pvr & tv settings -> energy savings -> wakeup command: sudo setwakeup.sh

    1. #!/bin/sh
    2. #$1 is the first argument to the script. It is the time in seconds since 1970
    3. echo 0 > /sys/class/rtc/rtc0/wakealarm #this clears your alarm.
    4. echo $1 > /sys/class/rtc/rtc0/wakealarm #this writes your alarm
    5. exit 0