Keep Windows awake when dbus is inhibited from idle, sleep

Abierto
#42,121 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
cpp, linux

Línea de trabajo

Start by tracing how /keep-awake currently uses the systemd integration and where it could observe changes to BlockInhibited. The issue proposes responding to idle, sleep, or shutdown inhibition with SetThreadExecutionState, then clearing the state when the property is empty; no files or tests are named. Done means Windows stays awake while the relevant inhibition is active and returns to normal afterward.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

feature

Is your feature request related to a problem? Please describe.

I use Copilot CLI in WSL2 and have /keep-awake enabled. That does call the org.freedesktop.login1.Manager.Inhibit API to inhibit idle detection. This does not, however, prevent my Windows machine from going idle and eventually to sleep.

Describe the solution you'd like

Monitor for property changed to BlockInhibited and SetThreadExecutionState accordingly e.g., probably when you see any of "idle", "sleep", or "shutdown"—which can be combined e.g., "sleep:idle"—call SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_CONTINUOUS). When the new property value is empty, SetThreadExecutionState(ES_CONTINUOUS) to clear it. As a service, you also have options to "discourage" shutting down when you see dbus signal "shutdown" through SCM messages.

Describe alternatives you've considered

I could use a systemd service to monitor events and write to stdout, listening to it from a WSL plugin. I could also use a number of executables including something like pipeferry or npiperelay to establish a pipe and listen to that from Windows. More moving parts, but no code signing requirement like WSL plugins either.

Additional context

See https://gist.github.com/heaths/b155cb7120b89a2a1c626f9d1cca2a0f (Rust) for how you can filter events to avoid getting flooded. This is a simple sync example but these I would expect would be infrequent enough to warrant proper signaling over overlapped IO.

systemd integration is enabled.

Lenguaje dominante
C++
Estrellas
34.4k
Forks
1.9k
Merge medio
1 d 23 h
PR fusionados (30 d)
166

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/WSL

Todos los issues de microsoft/WSL

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.