v0.9.22
This commit is contained in:
@@ -26,6 +26,7 @@ from PySide6.QtCore import (
|
||||
Signal, QPoint, QSize, Qt, QMimeData, QUrl, QTimer, QEvent, QRect, Slot, QRectF,
|
||||
QThread, QObject
|
||||
)
|
||||
from PySide6.QtDBus import QDBusConnection, QDBusMessage, QDBus
|
||||
|
||||
from constants import (
|
||||
APP_CONFIG, DEFAULT_FACE_BOX_COLOR, DEFAULT_PET_BOX_COLOR, DEFAULT_VIEWER_SHORTCUTS,
|
||||
@@ -3437,17 +3438,18 @@ class ImageViewer(QWidget):
|
||||
service, which is common on Linux desktops.
|
||||
"""
|
||||
try:
|
||||
cmd = [
|
||||
"dbus-send", "--session", "--print-reply",
|
||||
"--dest=org.freedesktop.ScreenSaver",
|
||||
msg = QDBusMessage.createMethodCall(
|
||||
"org.freedesktop.ScreenSaver",
|
||||
"/org/freedesktop/ScreenSaver",
|
||||
"org.freedesktop.ScreenSaver.Inhibit",
|
||||
"string:bagheeraview", # Application name
|
||||
"string:Viewing images" # Reason for inhibition
|
||||
]
|
||||
output = subprocess.check_output(cmd, text=True)
|
||||
# Extract the cookie from the output (e.g., "uint32 12345")
|
||||
self.inhibit_cookie = int(output.split()[-1])
|
||||
"org.freedesktop.ScreenSaver",
|
||||
"Inhibit"
|
||||
)
|
||||
msg.setArguments(["bagheeraview", "Viewing images"])
|
||||
reply = QDBusConnection.sessionBus().call(msg)
|
||||
if reply.type() == QDBusMessage.ReplyMessage:
|
||||
self.inhibit_cookie = reply.arguments()[0]
|
||||
else:
|
||||
self.inhibit_cookie = None
|
||||
except Exception as e:
|
||||
print(f"{UITexts.ERROR} inhibiting power management: {e}")
|
||||
self.inhibit_cookie = None
|
||||
@@ -3461,13 +3463,14 @@ class ImageViewer(QWidget):
|
||||
"""
|
||||
if hasattr(self, 'inhibit_cookie') and self.inhibit_cookie is not None:
|
||||
try:
|
||||
subprocess.Popen([
|
||||
"dbus-send", "--session",
|
||||
"--dest=org.freedesktop.ScreenSaver",
|
||||
msg = QDBusMessage.createMethodCall(
|
||||
"org.freedesktop.ScreenSaver",
|
||||
"/org/freedesktop/ScreenSaver",
|
||||
"org.freedesktop.ScreenSaver.UnInhibit",
|
||||
f"uint32:{self.inhibit_cookie}"
|
||||
])
|
||||
"org.freedesktop.ScreenSaver",
|
||||
"UnInhibit"
|
||||
)
|
||||
msg.setArguments([self.inhibit_cookie])
|
||||
QDBusConnection.sessionBus().call(msg, QDBus.NoBlock)
|
||||
self.inhibit_cookie = None
|
||||
except Exception as e:
|
||||
print(f"{UITexts.ERROR} uninhibiting: {e}")
|
||||
|
||||
Reference in New Issue
Block a user