-
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#540: listen for screensaver dbus messages
git-svn-id: https://xpra.org/svn/Xpra/trunk@18240 3bb7dfac-3a0b-4e04-842a-767bc560f471
- Loading branch information
Showing
2 changed files
with
100 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# This file is part of Xpra. | ||
# Copyright (C) 2018 Antoine Martin <[email protected]> | ||
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any | ||
# later version. See the file COPYING for details. | ||
|
||
|
||
try: | ||
#new recommended way of using the glib main loop: | ||
from dbus.mainloop.glib import DBusGMainLoop | ||
DBusGMainLoop(set_as_default=True) | ||
except: | ||
#beware: this import has side-effects: | ||
import dbus.glib | ||
assert dbus.glib | ||
import dbus #@Reimport | ||
|
||
|
||
NAME = "org.freedesktop.ScreenSaver" | ||
PATH = "/org/freedesktop/ScreenSaver" | ||
|
||
def main(): | ||
from xpra.platform import program_context | ||
with program_context("ScreenSaver-Listener", "ScreenSaver Listener"): | ||
dbus_session = dbus.SessionBus() | ||
def active_changed(active): | ||
print("screensaver active status changed: %s" % (active, )) | ||
dbus_session.add_signal_receiver(active_changed, "ActiveChanged", NAME, path=PATH) | ||
from xpra.gtk_common.gobject_compat import import_glib | ||
glib = import_glib() | ||
loop = glib.MainLoop() | ||
loop.run() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters