diff --git a/projector.py b/projector.py index c0923fe..923e9fa 100755 --- a/projector.py +++ b/projector.py @@ -173,10 +173,18 @@ class SongProjector: if sys.platform.startswith("win"): # Windows: ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED # 0x80000000 | 0x00000002 | 0x00000001 - ctypes.windll.kernel32.SetThreadExecutionState(0x80000003) + # Uporabimo c_uint za zagotovitev pravilnega tipa + ctypes.windll.kernel32.SetThreadExecutionState(ctypes.c_uint(0x80000003)) elif sys.platform == "linux": - # Linux: poskusimo z xset (če smo v X11) - subprocess.Popen(["xset", "s", "off", "-dpms"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + # Zaženi inhibitor, dokler tvoj program dela (hrani handle!) + inhibitor = subprocess.Popen([ + "gnome-session-inhibit", + "--inhibit", "idle", + "--inhibit", "suspend", + "--reason", "Projecting lyrics", + "sleep", "infinity" + ]) + except Exception as e: print(f"Napaka pri preprečevanju spanja: {e}") @@ -488,13 +496,18 @@ class SongProjector: if sys.platform.startswith("win"): try: # ES_CONTINUOUS (0x80000000) - ctypes.windll.kernel32.SetThreadExecutionState(0x80000000) + ctypes.windll.kernel32.SetThreadExecutionState(ctypes.c_uint(0x80000000)) except: pass elif sys.platform == "linux": try: # Ponovno vklopi ohranjevalnik in DPMS (privzete vrednosti) subprocess.Popen(["xset", "s", "on", "+dpms"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + + # Za Wayland/DBus inhibit običajno ni treba eksplicitno sprostiti, + # če se proces konča, vendar bi za popolnost lahko uporabili UnInhibit, + # če bi shranili cookie. Ker ga nismo, se zanašamo na to, da DBus + # samodejno sprosti inhibit ob zaprtju povezave/procesa. except: pass