Fixed sleep inhibition error

This commit is contained in:
Deniz Şafak
2025-08-25 02:19:05 +03:00
parent 528343f375
commit aa98547456
2 changed files with 21 additions and 11 deletions
+2
View File
@@ -1,6 +1,8 @@
# 1.1.7 (ğre-release)
- Added MPS GPU acceleration support for Silicon Mac, mentioned in https://github.com/denizsafak/abogen/issues/32#issuecomment-3155902040 by @jefro108
- Added word-by-word karaoke highlighting feature by @robmckinnon in PR #65
- Fixed sleep inhibition error occurring on some Linux systems that do not use systemd, mentioned in #67 by @hendrack
- Improvements in code and documentation.
# 1.1.6
- Improved EPUB chapter detection: Now reliably detects chapters from NAV HTML (TOC) files, even in non-standard EPUBs, fixes the issue mentioned by @jefro108 in #33
+8
View File
@@ -3,6 +3,7 @@ import sys
import json
import warnings
import platform
import shutil
import subprocess
import re
from threading import Thread
@@ -286,6 +287,8 @@ def prevent_sleep_start():
# Add program name and reason for inhibition
program_name = PROGRAM_NAME
reason = "Prevent sleep during abogen process"
# Only attempt to use systemd-inhibit if it's available on the system.
if shutil.which("systemd-inhibit"):
_sleep_procs["Linux"] = create_process(
[
"systemd-inhibit",
@@ -297,6 +300,11 @@ def prevent_sleep_start():
"infinity",
]
)
else:
# Non-systemd distro or systemd tools not installed: skip inhibition rather than crash
print(
"systemd-inhibit not found: skipping sleep inhibition on this Linux system."
)
def prevent_sleep_end():