Skip to content

Commit b674e27

Browse files
authored
Update docs: Add Method Tables (#194)
Update docs ----------- * Remove old part of documentation which explains how the wakepy Modes work. The info is outdated and is covered by the Method docs. * Add tables of Methods in the Modes page
1 parent 2ef6512 commit b674e27

File tree

2 files changed

+21
-106
lines changed

2 files changed

+21
-106
lines changed

docs/source/methods-reference.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ print('SPI_GETSCREENSAVETIMEOUT', retval.value)
9494

9595
## keep.presenting
9696

97-
97+
(keep-presenting-org-gnome-sessionmanager)=
9898
### org.gnome.SessionManager
9999

100100
- **Name**: `org.gnome.SessionManager`
@@ -120,8 +120,6 @@ print('SPI_GETSCREENSAVETIMEOUT', retval.value)
120120
(keep-presenting-windows-stes)=
121121
### SetThreadExecutionState
122122

123-
124-
125123
- **Name**: `SetThreadExecutionState`
126124
- **Introduced in**: wakepy 0.1.0
127125
- **How it works**: Exactly the same as the [keep.running](keep-running-windows-stes), but using ES_CONTINUOUS, ES_SYSTEM_REQUIRED *and* ES_DISPLAY_REQUIRED flags when activating.

docs/source/modes.md

Lines changed: 20 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44

55
The available modes are
6-
| Wakepy mode | What it does |
7-
| ----------------- | --------------------------------------------------- |
8-
| `keep.running` | Automatic sleep is prevented |
9-
| `keep.presenting` | Automatic sleep, screensaver & screenlock prevented |
6+
| Wakepy mode | What it does |
7+
| ---------------------------------------- | --------------------------------------------------- |
8+
| [keep.running](#keep-running-mode) | Automatic sleep is prevented |
9+
| [keep.presenting](#keep-presenting-mode) | Automatic sleep, screensaver & screenlock prevented |
1010

1111
## Entering a mode
1212

@@ -27,119 +27,36 @@ with keep.running() as m:
2727
```
2828
````
2929

30-
## wakepy.keep.running
30+
31+
(keep-running-mode)=
32+
## keep.running
3133

3234

3335
**Does keep.running prevent manually putting system to sleep?** All the methods, if not otherwise specified, only prevent the *automatic, idle timer timeout based* sleeping, so it is still possible to put system to sleep by selecting Suspend/Sleep from a menu, closing the laptop lid or pressing a power key, for example. One exception is systemd mask method on Linux, which prevents suspend altogether.
3436

3537
**Can I lock my computer after entered `keep.running` mode?**: Yes, and you probably should, if you're not near your computer. The programs will continue execution regardless of the lock.
3638

3739

40+
| Platform | DE | Method |
41+
| -------- | ----- | ------------------------------------------------------------------ |
42+
| Linux | GNOME | [org.gnome.SessionManager](#keep-running-org-gnome-sessionmanager) |
43+
| MacOS | * | [caffeinate](#keep-running-macos-caffeinate) |
44+
| Windows | * | [SetThreadExecutionState](#keep-running-windows-stes) |
3845

39-
::::{tab-set}
40-
41-
:::{tab-item} Windows
42-
:sync: windows
43-
44-
**How it works?**: The [SetThreadExecutionState](https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate?redirectedfrom=MSDN) is called with the `ES_CONTINUOUS` and `ES_SYSTEM_REQUIRED` flags to acquire a lock when entering the context. On exit, these flags are removed.
45-
46-
**How to check it?**: Run `powercfg -requests` in an elevated PowerShell.
47-
48-
**Multiprocess safe?**: Yes.
49-
50-
:::
51-
52-
:::{tab-item} Linux
53-
:sync: linux
54-
55-
On wakepy 0.7.0, the current implementation of `keep.presenting` is same as of `keep.running`. This is to be changed in a future release.
56-
57-
58-
```{warning}
59-
Current D-Bus -based implementation (v.0.7.0) incorrectly prevents also screenlock/screensaver (remember to lock manually!). This will be fixed in a future release.
60-
```
61-
62-
63-
:::
64-
65-
:::{tab-item} Mac
66-
:sync: mac
67-
68-
**How it works?**: Wakepy launches a [`caffeinate`](https://ss64.com/osx/caffeinate.html) subprocess when setting keepawake, and terminates the subprocess when unsetting.
69-
70-
**How to check it?**: There should be a subprocess visible when a lock is taken, but this is untested.
71-
72-
**Multiprocess safe?**: Not tested.
73-
74-
75-
:::
76-
77-
::::
78-
79-
80-
81-
82-
## wakepy.keep.presenting
46+
(keep-presenting-mode)=
47+
## keep.presenting
8348

8449

8550
**Does keep.presenting prevent manually putting system to sleep?** All the methods, if not otherwise specified, only prevent the *automatic, idle timer timeout based* sleeping and screensaver/screenlock, so it is still possible to put system to sleep by selecting Suspend/Sleep from a menu, closing the laptop lid or pressing a power key, for example. It is also possible to manually start the screenlock/screensaver while presenting mode is on.
8651

8752
**Is my computer locked automatically in `keep.presenting` mode?**: No. Entering a screenlock automatically would stop presenting the content.
8853

89-
90-
::::{tab-set}
91-
92-
:::{tab-item} Windows
93-
:sync: windows
94-
95-
**How it works?**: The [SetThreadExecutionState](https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate?redirectedfrom=MSDN) is called with the `ES_CONTINUOUS`, `ES_SYSTEM_REQUIRED` and `ES_DISPLAY_REQUIRED` flags to acquire a lock when entering the context. On exit, these flags are removed.
96-
97-
**How to check it?**: Run `powercfg -requests` in an elevated PowerShell.
98-
99-
**Multiprocess safe?**: Yes.
100-
101-
:::
102-
103-
:::{tab-item} Linux
104-
:sync: linux
105-
106-
107-
108-
**How it works?**: Wakepy uses, depending on what is installed, either (in this order)
109-
1. D-Bus to call `Inhibit` method of [`org.freedesktop.ScreenSaver`](https://people.freedesktop.org/~hadess/idle-inhibition-spec/re01.html) (try first using jeepney, and then using dbus-python)
110-
3. `systemctl mask`
111-
112-
113-
```{warning}
114-
The systemd mask method will inhibit all forms of sleep (including hibernation and sleep initialized by the user). It will change global system settings, so if your process exits abruptly, you'll have to undo the change.
115-
```
116-
117-
**How to check it?**: For D-Bus `org.freedesktop.ScreenSaver` based solution, there is no possibility to check it afterwards. You may monitor the call with [`dbus-monitor`](https://dbus.freedesktop.org/doc/dbus-monitor.1.html), though. For systemd mask based solution, you'll see that the Suspend option is removed from the menu altogether.
118-
119-
**Which Desktop Environments are supported?** For D-Bus `org.freedesktop.ScreenSaver` method, you have to use a Freedesktop-compliant Desktop Environment, for example GNOME or KDE. The list of supported DEs will be expanded in the future. For systemd solution, any Linux running systemd works, but you need sudo.
120-
121-
**Multiprocess safe?**: DBus: yes, systemd mask: no.
122-
123-
124-
:::
125-
126-
127-
128-
:::{tab-item} Mac
129-
:sync: mac
130-
131-
**How it works?**: Wakepy launches a [`caffeinate`](https://ss64.com/osx/caffeinate.html) subprocess with `-d -u -t 2592000` arguments when entering `keep.presenting` mode, and terminates the subprocess when exiting the mode.
132-
133-
**How to check it?**: There should be a subprocess visible when a lock is taken, but this is untested.
134-
135-
**Multiprocess safe?**: Not tested.
136-
137-
:::
138-
139-
140-
::::
141-
142-
54+
| Platform | DE | Method |
55+
| -------- | --------------- | --------------------------------------------------------------------------- |
56+
| Linux | GNOME | [org.gnome.SessionManager](#keep-presenting-org-gnome-sessionmanager) |
57+
| Linux | GNOME + others? | [org.freedesktop.ScreenSaver](#keep-presenting-org-freedesktop-screensaver) |
58+
| MacOS | * | [caffeinate](#keep-presenting-macos-caffeinate) |
59+
| Windows | * | [SetThreadExecutionState](#keep-presenting-windows-stes) |
14360

14461

14562
## General questions

0 commit comments

Comments
 (0)