Skip to content
This repository was archived by the owner on Jun 1, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions host/src/pack/dpkg/etc/rc.mwc
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions host/src/pack/dpkg/etc/systemd/user/sleep-inhibitor.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Unit]
Description=Sleep Inhibitor Service

[Service]
ExecStart=/usr/bin/python3 -u /usr/local/bin/%p

[Install]
WantedBy=default.target
12 changes: 12 additions & 0 deletions host/src/pack/dpkg/opt/cfc/mwc/bin/is-wakelock-active
Original file line number Diff line number Diff line change
@@ -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')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to check if android guest is active.
If no android app/windows is active. We don't need to do the adb check.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 2 checks if guest is active or not using adb.
If not adb, we need to use qemu process for checking the activeness of guest.

if echo "$state" | grep 'SCREEN_BRIGHT_WAKE_LOCK'; then
exit 254
else
exit 0
fi
else
exit 0
fi
6 changes: 6 additions & 0 deletions host/src/pack/dpkg/opt/cfc/mwc/bin/sleep-inhibitor.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
plugins:
#Inhibit sleep if wakelock is held
- path: is-wakelock-active
name: Wakelock active
what: sleep
period: 0.5