Printrun
Printrun copied to clipboard
Preventing PC to go to sleep while printing
Is it possible to make Pronterface keep PC from going to sleep while printing? I do not want to use system setttings from that as I do want PC to go to sleep when not used, except when it is left on long time print job.
I cannot relay on me remembering that I have to turn sleep off. It would be great if Pronterface can handle that. I guess it should be enough for Printerface to send some background messages to the system (like moving mouse or clicking keyboard) so it thinks there is active use and sleep mode is not initiated.
Actually Pronterface IS supposed to keep the PC awake.
However, it seems to be unable to properly communicate with the desktop's power manager (or at least, it doesn't like XFCE's implementation).
For example, I get this error when a print starts (Using 2.0.0.rc7 from Debian's repo):
Print started at: 10:17:41
Failed to set power settings:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/printrun/pronsole.py", line 1251, in startcb
powerset_print_start(reaso0n = "Preventing sleep during print")
File "/usr/lib/python3/dist-packages/printrun/power/__init__.py", line 136, in powerset_print_start
inhibit_sleep(reason)
File "/usr/lib/python3/dist-packages/printrun/power/__init__.py", line 66, in inhibit_sleep
inhibit_sleep_token = inhibit_sleep_handler.Inhibit("printrun", reason)
File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 141, in __call__
return self._connection.call_blocking(self._named_service,
File "/usr/lib/python3/dist-packages/dbus/connection.py", line 652, in call_blocking
reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name :1.66 was not provided by any .service files
The print goes on ahead, without incident, and my PC is not allowed to go to sleep anyway (I have that option turned off in XFCE power manager's settings, because the PC has other stuff to do that requires it to always be on), so this error has no material effect on my setup.
Still, it does need addressed.