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) # 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 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 - 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 # 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 - 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
+19 -11
View File
@@ -3,6 +3,7 @@ import sys
import json import json
import warnings import warnings
import platform import platform
import shutil
import subprocess import subprocess
import re import re
from threading import Thread from threading import Thread
@@ -286,17 +287,24 @@ def prevent_sleep_start():
# Add program name and reason for inhibition # Add program name and reason for inhibition
program_name = PROGRAM_NAME program_name = PROGRAM_NAME
reason = "Prevent sleep during abogen process" reason = "Prevent sleep during abogen process"
_sleep_procs["Linux"] = create_process( # Only attempt to use systemd-inhibit if it's available on the system.
[ if shutil.which("systemd-inhibit"):
"systemd-inhibit", _sleep_procs["Linux"] = create_process(
f"--who={program_name}", [
f"--why={reason}", "systemd-inhibit",
"--what=sleep", f"--who={program_name}",
"--mode=block", f"--why={reason}",
"sleep", "--what=sleep",
"infinity", "--mode=block",
] "sleep",
) "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(): def prevent_sleep_end():