diff --git a/host/src/pack/dpkg/etc/rc.mwc b/host/src/pack/dpkg/etc/rc.mwc index 17ca32d..9eb4a7e 100755 --- a/host/src/pack/dpkg/etc/rc.mwc +++ b/host/src/pack/dpkg/etc/rc.mwc @@ -12,6 +12,23 @@ do chmod 666 /dev/shm/looking-glass$i done +echo "Set sleep-inhibitor if not already done..." >> /opt/cfc/mwc.log +if [ ! -d /usr/local/share/sleep-inhibitor/plugins/is-wakelock-active ] +then + cp /opt/cfc/mwc/bin/is-wakelock-active /usr/local/share/sleep-inhibitor/plugins/ +fi +if [ ! -d /etc/sleep-inhibitor.conf ] +then + cp /opt/cfc/mwc/bin/sleep-inhibitor.conf /etc/ +fi +if [! -d /etc/systemd/system/sleep-inhibitor.service ] +then + cp /etc/systemd/user/sleep-inhibitor.service /etc/systemd/system/ +fi + +systemctl daemon-reload +systemctl start sleep-inhibitor + echo "Start mwc daemon service ..." >> /opt/cfc/mwc.log /opt/cfc/mwc/bin/mwc_hostdaemon 3000 >> /opt/cfc/mwc.log exit 0 diff --git a/host/src/pack/dpkg/etc/systemd/user/sleep-inhibitor.service b/host/src/pack/dpkg/etc/systemd/user/sleep-inhibitor.service new file mode 100644 index 0000000..4adb79c --- /dev/null +++ b/host/src/pack/dpkg/etc/systemd/user/sleep-inhibitor.service @@ -0,0 +1,8 @@ +[Unit] +Description=Sleep Inhibitor Service + +[Service] +ExecStart=/usr/bin/python3 -u /usr/local/bin/%p + +[Install] +WantedBy=default.target diff --git a/host/src/pack/dpkg/opt/cfc/mwc/bin/is-wakelock-active b/host/src/pack/dpkg/opt/cfc/mwc/bin/is-wakelock-active new file mode 100755 index 0000000..c948ebe --- /dev/null +++ b/host/src/pack/dpkg/opt/cfc/mwc/bin/is-wakelock-active @@ -0,0 +1,12 @@ +#! /bin/sh +if adb get-state 1>/dev/null 2>&1 +then + state=$(adb shell dumpsys power | grep -oE 'SCREEN_BRIGHT_WAKE_LOCK') + if echo "$state" | grep 'SCREEN_BRIGHT_WAKE_LOCK'; then + exit 254 + else + exit 0 + fi +else + exit 0 +fi diff --git a/host/src/pack/dpkg/opt/cfc/mwc/bin/sleep-inhibitor.conf b/host/src/pack/dpkg/opt/cfc/mwc/bin/sleep-inhibitor.conf new file mode 100644 index 0000000..310cb03 --- /dev/null +++ b/host/src/pack/dpkg/opt/cfc/mwc/bin/sleep-inhibitor.conf @@ -0,0 +1,6 @@ +plugins: + #Inhibit sleep if wakelock is held + - path: is-wakelock-active + name: Wakelock active + what: sleep + period: 0.5