Skip to content

Instantly share code, notes, and snippets.

@qwazix
Last active January 21, 2017 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qwazix/290a25576f8c1f80cbc929f5a5d3f27e to your computer and use it in GitHub Desktop.
Save qwazix/290a25576f8c1f80cbc929f5a5d3f27e to your computer and use it in GitHub Desktop.
Inhibit suspend in gnome while rendering in blender
# © Michael Demetriou 2017
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
bl_info = {
"name": "Inhibit suspend while rendering - for gnome",
"author": "Michael Demetriou",
"version": (1, 0),
"blender": (2, 78, 0),
"description": "Inhibits system suspend while rendering",
"warning": "",
"wiki_url": "",
"tracker_url": "https://gist.github.com/qwazix/290a25576f8c1f80cbc929f5a5d3f27e",
"category": "System"}
###########################################################################
import bpy
import dbus
from bpy.app.handlers import persistent
cookie = 0
_session_bus = dbus.SessionBus()
_dbus_screensaver = _session_bus.get_object('org.gnome.SessionManager','/org/gnome/SessionManager')
inhibit = _dbus_screensaver.get_dbus_method('Inhibit','org.gnome.SessionManager')
uninhibit = _dbus_screensaver.get_dbus_method('Uninhibit','org.gnome.SessionManager')
@persistent
def render_pre_handler(dummy):
global cookie
cookie = inhibit("BlenderRendering",dbus.UInt32(0),"inhibiting",dbus.UInt32(4));
@persistent
def render_post_handler(dummy):
global cookie
uninhibit(dbus.UInt32(cookie));
def register():
bpy.app.handlers.render_pre.append(render_pre_handler)
bpy.app.handlers.render_post.append(render_post_handler)
def unregister():
bpy.app.handlers.render_pre.remove(render_pre_handler)
bpy.app.handlers.render_post.remove(render_post_handler)
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment