From 46c3a59e91d574f90e5112dc1e7ca637eff3dce7 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Wed, 10 Apr 2019 17:59:49 +0000
Subject: LinHES-system: enableIRWake.sh: will enable remotes to wake from
 sleep.

uses /usr/MythVantage/templates/remotes/receiver_usb.id to determine what vendor and product ids should wake be enabled
---
 abs/core/LinHES-system/LinHES-session  |  1 +
 abs/core/LinHES-system/PKGBUILD        |  7 ++++---
 abs/core/LinHES-system/enableIRWake.sh | 22 ++++++++++++++++++++++
 3 files changed, 27 insertions(+), 3 deletions(-)
 create mode 100755 abs/core/LinHES-system/enableIRWake.sh

diff --git a/abs/core/LinHES-system/LinHES-session b/abs/core/LinHES-system/LinHES-session
index 7960bf5..bf71980 100755
--- a/abs/core/LinHES-system/LinHES-session
+++ b/abs/core/LinHES-system/LinHES-session
@@ -411,6 +411,7 @@ fi
 # this is done so that starting mythtv can loop.
 $WM &
 pid=$!
+/usr/LH/bin/enableIRWake.sh &
 mouse_move
 keylaunch
 unclutter
diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD
index 3d0b412..8728913 100755
--- a/abs/core/LinHES-system/PKGBUILD
+++ b/abs/core/LinHES-system/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-system
 pkgver=8.6.0
-pkgrel=2
+pkgrel=3
 arch=('x86_64')
 install=system.install
 pkgdesc="Everything that makes LinHES an automated system"
@@ -17,7 +17,7 @@ binfiles="LinHES-start optimize_mythdb.py myth_mtc.py
  mythfrontend-start set_windowmanager.sh myth_status.py myth_status.sh
  install_supplemental_service.sh get_airplay_key importfiles.sh
  lh_system_backup lh_system_backup_job lh_system_restore lh_system_restore_job
- lh_system_host_update lh_system_all_host_update
+ lh_system_host_update lh_system_all_host_update enableIRWake.sh
  add_storage.py balance_storage_groups.py empty_storage_groups.py
  remove_storage.py diskspace.sh cacheclean lh_backend_control.sh
  create_media_dirs.sh msg_client.py msg_daemon.py mythvidexport.py
@@ -80,7 +80,7 @@ package() {
 
 }
 
-md5sums=('c6e6b83a1f4c35ef4501e277657ab2ac'
+md5sums=('9e941d6c6d4edd56f1a89a7ab566763c'
          'ad5e144999b6f37931dea799c2761c7e'
          'de32a1c50101265dd7f6ca5037f7a26a'
          '2d7b8414ddce5f401331342ac1529c22'
@@ -102,6 +102,7 @@ md5sums=('c6e6b83a1f4c35ef4501e277657ab2ac'
          'eab2d188992b1ac561e0ba968544d7a3'
          '74e17d6f7453c52d56fecaed5c3f6ad5'
          '47e093e8cfe4b5b96602358e1f540832'
+         '4cc3401a94500fad269b25c60d99cc4d'
          '727a886a1ba237906f48cda2e4e7844b'
          '0c81e5cad656f6260e39cd7585b1421a'
          'e5bb027c54a2727d0bcf8d6fb357ba32'
diff --git a/abs/core/LinHES-system/enableIRWake.sh b/abs/core/LinHES-system/enableIRWake.sh
new file mode 100755
index 0000000..5b971b7
--- /dev/null
+++ b/abs/core/LinHES-system/enableIRWake.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+for vendProdID in `lsusb | sed -e 's/.*ID \([a-f0-9]\+:[a-f0-9]\+\).*/\1/g'`
+do
+    foundRemote=`grep -i "$vendProdID" /usr/MythVantage/templates/remotes/receiver_usb.id`
+    if [[ $? = 0 ]]
+    then
+        #echo Found: $foundRemote
+        vendID=`echo $vendProdID | cut -d":" -f1`
+        prodID=`echo $vendProdID | cut -d":" -f2`
+        for usbDevice in `grep . /sys/bus/usb/devices/*/power/wakeup | cut -d"/" -f6`
+        do
+            foundVendID=`cat /sys/bus/usb/devices/$usbDevice/idVendor`
+            foundProdID=`cat /sys/bus/usb/devices/$usbDevice/idProduct`
+            if [[ $foundVendID == $vendID && $foundProdID == $prodID ]]
+            then
+                echo "Enable wake for $foundRemote on $usbDevice"
+                sudo sh -c "echo 'enabled' > /sys/bus/usb/devices/$usbDevice/power/wakeup"
+            fi
+        done
+    fi
+done
-- 
cgit v0.12

