/usr/lib/gnome-tweak-tool/gnome-tweak-tool-lid-inhibitor is in gnome-tweak-tool 3.18.1-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #! /usr/bin/python
import gi
gi.require_version("GLib", "2.0")
from gi.repository import Gio, GLib
def on_activate(app):
if app._inhibitor:
return
app.hold()
bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
var, fdlist = bus.call_with_unix_fd_list_sync('org.freedesktop.login1',
'/org/freedesktop/login1',
'org.freedesktop.login1.Manager',
'Inhibit',
GLib.Variant('(ssss)',
('handle-lid-switch',
'gnome-tweak-tool-lid-inhibitor',
'user preference',
'block')),
None, 0, -1, None, None)
app._inhibitor = Gio.UnixInputStream(fd=fdlist.steal_fds()[var[0]])
def on_quit_action(action, param, app):
app.quit()
if __name__ == '__main__':
app = Gio.Application(application_id='org.gnome.tweak-tool.lid-inhibitor', flags=0)
app.connect('activate', on_activate)
app._inhibitor = None
action = Gio.SimpleAction(name='quit')
app.add_action(action)
action.connect('activate', on_quit_action, app)
app.run([])
|