Add the installer, uninstaller, and generated docs
This commit is contained in:
Executable
+61
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
|
||||
# blob:summary=Monitor sleep preparation and lock before suspend
|
||||
# blob:group=system
|
||||
# blob:hidden=true
|
||||
|
||||
consume_sleep_events() {
|
||||
local line sleep_lock
|
||||
sleep_lock="$BLOB_PATH/bin/blob-system-sleep"
|
||||
|
||||
while IFS= read -r line; do
|
||||
if [[ $line == *"boolean true"* ]]; then
|
||||
"$sleep_lock"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
monitor_sleep_events() {
|
||||
local monitor_fd monitor_pid status
|
||||
|
||||
coproc SLEEP_EVENTS {
|
||||
exec dbus-monitor --system \
|
||||
"type='signal',sender='org.freedesktop.login1',interface='org.freedesktop.login1.Manager',member='PrepareForSleep'"
|
||||
}
|
||||
monitor_fd=${SLEEP_EVENTS[0]}
|
||||
monitor_pid=$SLEEP_EVENTS_PID
|
||||
|
||||
cleanup_monitor() {
|
||||
kill "$monitor_pid" 2>/dev/null || true
|
||||
wait "$monitor_pid" 2>/dev/null || true
|
||||
}
|
||||
trap cleanup_monitor EXIT
|
||||
|
||||
consume_sleep_events <&"$monitor_fd"
|
||||
status=$?
|
||||
cleanup_monitor
|
||||
trap - EXIT
|
||||
|
||||
return "$status"
|
||||
}
|
||||
|
||||
case ${1:-} in
|
||||
--consume)
|
||||
consume_sleep_events
|
||||
exit 0
|
||||
;;
|
||||
--inhibited)
|
||||
monitor_sleep_events
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
sleep_monitor="$BLOB_PATH/bin/blob-system-sleep-monitor"
|
||||
|
||||
exec systemd-inhibit \
|
||||
--what=sleep \
|
||||
--mode=delay \
|
||||
--who=Blob \
|
||||
--why="Lock screen before suspend" \
|
||||
"$sleep_monitor" --inhibited
|
||||
Reference in New Issue
Block a user