From 380f242cc17f871d0830ced59bbe9f891414e76a Mon Sep 17 00:00:00 2001
From: shakemid <k-cima@kendama.asia>
Date: Thu, 31 Aug 2017 09:41:03 +0900
Subject: [PATCH] Fix pcsensor.sh to check if hid driver is loaded

---
 pcsensor.sh | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/pcsensor.sh b/pcsensor.sh
index 6f8e4d8..5c17ff2 100755
--- a/pcsensor.sh
+++ b/pcsensor.sh
@@ -10,6 +10,12 @@ moduleid=$( modinfo | awk '$6 == "hid" { print $1 }' )
 
 cd "$( dirname "$0" )" || exit 1
 
-modunload -i "$moduleid"
+if [ -n "$moduleid" ]; then 
+    modunload -i "$moduleid"
+fi
+
 ./pcsensor "$@"
-modload "$hiddriver"
+
+if [ -n "$moduleid" ]; then 
+    modload "$hiddriver"
+fi