{"id":444,"date":"2016-01-11T22:13:59","date_gmt":"2016-01-11T21:13:59","guid":{"rendered":"https:\/\/www.anginf.de\/?p=444"},"modified":"2016-01-11T22:23:59","modified_gmt":"2016-01-11T21:23:59","slug":"kodi-spinup-hdd-when-screensaver-was-deactivated","status":"publish","type":"post","link":"https:\/\/www.anginf.de\/?p=444","title":{"rendered":"KODI: Spinup HDD when Screensaver was deactivated"},"content":{"rendered":"<p>When trying to access my recordings on my NAS, kodi <em>seems<\/em> to stop working for a short while when the NAS realizes that it is being accessed and starts spinning up the discs. I figured that it would be nice for the NAS to spin up earlier, if the screen saver of a &#8222;connected KODI&#8220; is deactivated.<\/p>\n<p>After enabling the JSON-RPC-TCP 9090-Port on Kodi (In System\/Settings\/Network\/Services activate &#8222;Allow programs on this system to control Kodi for localhost access only&#8220; and &#8222;Allow programs on other systems to control Kodi for access from other computers as well&#8220;), this script should be run at boottime on the NAS. Make sure to replace the accessed discs with your \/dev\/sdX-entries on your system. Also replace HOSTNAME with the host which as Kodi running, if the discs are in use on the same host, replace it with &#8222;localhost&#8220;.<\/p>\n<p>The command must be run as root.<\/p>\n<p><code>onidlespinupdiscs.sh<\/code>:<\/p>\n<pre lang=\"bash\">\r\n#!\/bin\/bash\r\n# Must be run as root\r\nwhile true\r\ndo\r\n  netcat -d HOSTNAME 9090 | (\r\n    cnt=0\r\n    line=\r\n    while read -N 1 c; do\r\n      line=\"$line$c\"\r\n      if [ \"$c\" = \"{\" ]; then\r\n        cnt=$((cnt+1))\r\n      elif [ \"$c\" = \"}\" ]; then\r\n        cnt=$((cnt-1))\r\n        if [ $cnt -eq 0 ]; then\r\n          printf \"%s\\n\" \"$line\"\r\n          line=\r\n        fi\r\n      fi\r\n    done\r\n  ) | while read line\r\n  do\r\n    match=$(echo ${line} | grep -c \"GUI.OnScreensaverDeactivated\")\r\n    if [ $match -eq 1 ]; then\r\n      dd if=\/dev\/sdb bs=4096 count=1 of=\/dev\/null iflag=direct >\/dev\/null 2>&1 &\r\n      dd if=\/dev\/sdc bs=4096 count=1 of=\/dev\/null iflag=direct >\/dev\/null 2>&1 &\r\n    fi\r\n  done\r\n  sleep 60\r\ndone\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>When trying to access my recordings on my NAS, kodi seems to stop working for a short while when the NAS realizes that it is being accessed and starts spinning up the discs. I figured that it would be nice for the NAS to spin up earlier, if the screen saver of a &#8222;connected KODI&#8220; &hellip; <a href=\"https:\/\/www.anginf.de\/?p=444\" class=\"more-link\"><span class=\"screen-reader-text\">KODI: Spinup HDD when Screensaver was deactivated<\/span> weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-444","post","type-post","status-publish","format-standard","hentry","category-allgemein"],"_links":{"self":[{"href":"https:\/\/www.anginf.de\/index.php?rest_route=\/wp\/v2\/posts\/444","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.anginf.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.anginf.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.anginf.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.anginf.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=444"}],"version-history":[{"count":2,"href":"https:\/\/www.anginf.de\/index.php?rest_route=\/wp\/v2\/posts\/444\/revisions"}],"predecessor-version":[{"id":446,"href":"https:\/\/www.anginf.de\/index.php?rest_route=\/wp\/v2\/posts\/444\/revisions\/446"}],"wp:attachment":[{"href":"https:\/\/www.anginf.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anginf.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anginf.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}