It’s just data

Inhibiting Suspend

The interface is a bit low level, but workable:

require 'dbus' # gem install ruby-dbus
bus = DBus::SessionBus.instance
sm = bus.service('org.gnome.SessionManager').object('/org/gnome/SessionManager')
sm.default_iface = 'org.gnome.SessionManager'
cookie = sm.Inhibit($0, 0, 'inhibiting', 4).first
at_exit { cookie = sm.Uninhibit(cookie) if sm.IsInhibited(4).first }

Note: the call to Uninhibit is optional — it will occur on process exit anyway.

Hat tip to JanuZ.

For best results, add the following before these lines:

ENV['DISPLAY'] ||= ':0'
Posted by Sam Ruby at

Add your comment