Initial commit. Add poc hack script
This commit is contained in:
commit
916b3c2836
34
proof-of-concept.sh
Executable file
34
proof-of-concept.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
LOCK=/tmp/after-lock.lock
|
||||||
|
INITIAL_DELAY=3
|
||||||
|
LOOP_DELAY=17
|
||||||
|
|
||||||
|
if ! mkdir "${LOCK}" &> /dev/null; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
cleanup() {
|
||||||
|
rmdir "${LOCK}"
|
||||||
|
}
|
||||||
|
trap cleanup INT TERM EXIT
|
||||||
|
|
||||||
|
screensaver_isactive() {
|
||||||
|
[[ $(qdbus org.kde.screensaver /ScreenSaver org.freedesktop.ScreenSaver.GetActive) = "true" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
display_shouldsleep() {
|
||||||
|
if ! xset q | grep -q Monitor; then
|
||||||
|
return 0
|
||||||
|
elif [[ "$(xset q | grep -oP '(?<=Monitor is )\w+')" = 'On' ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
sleep "${INITIAL_DELAY}"
|
||||||
|
while screensaver_isactive; do
|
||||||
|
if display_shouldsleep; then
|
||||||
|
xset dpms force suspend
|
||||||
|
fi
|
||||||
|
sleep "${LOOP_DELAY}"
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user