From 1e78bdb4689601d3b4b774cff2ad9dbdc00326c7 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 18 Feb 2011 13:52:34 +0000 Subject: [PATCH] xsetbg (DBus version). git-svn-id: file:///home/phd/archive/SVN/xsetbg/trunk@49 143022c7-580b-0410-bae3-87f2bf5d3141 --- xsetbg-dbus-change | 2 ++ xsetbg-dbus-client.py | 31 ++++++++++++++++++ xsetbg-dbus-force | 2 ++ xsetbg-dbus-restart | 2 ++ xsetbg-dbus-start | 4 +++ xsetbg-dbus-stop | 2 ++ xsetbg-dbus.py | 51 +++++++++++++++++++++++++++++ xsetbg-change => xsetbg-http-change | 0 xsetbg-force => xsetbg-http-force | 0 xsetbg-http-restart | 2 ++ xsetbg-http-start | 4 +++ xsetbg-stop => xsetbg-http-stop | 0 xsetbg-restart | 2 -- xsetbg-start | 4 --- 14 files changed, 100 insertions(+), 6 deletions(-) create mode 100755 xsetbg-dbus-change create mode 100644 xsetbg-dbus-client.py create mode 100755 xsetbg-dbus-force create mode 100755 xsetbg-dbus-restart create mode 100755 xsetbg-dbus-start create mode 100755 xsetbg-dbus-stop create mode 100755 xsetbg-dbus.py rename xsetbg-change => xsetbg-http-change (100%) rename xsetbg-force => xsetbg-http-force (100%) create mode 100755 xsetbg-http-restart create mode 100755 xsetbg-http-start rename xsetbg-stop => xsetbg-http-stop (100%) delete mode 100755 xsetbg-restart delete mode 100755 xsetbg-start diff --git a/xsetbg-dbus-change b/xsetbg-dbus-change new file mode 100755 index 0000000..99a4d22 --- /dev/null +++ b/xsetbg-dbus-change @@ -0,0 +1,2 @@ +#! /bin/sh +exec "$HOME/lib/xsetbg"/xsetbg-dbus-client.py change diff --git a/xsetbg-dbus-client.py b/xsetbg-dbus-client.py new file mode 100644 index 0000000..7d2e337 --- /dev/null +++ b/xsetbg-dbus-client.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +"""XSetBg DBus client + +""" + +__version__ = "$Revision: 48 $"[11:-2] +__revision__ = "$Id: xsetbg-wsgi.py 48 2011-02-18 13:35:39Z phd $"[5:-2] +__date__ = "$Date: 2011-02-18 16:35:39 +0300 (Fri, 18 Feb 2011) $"[7:-2] + +__author__ = "Oleg Broytman " +__copyright__ = "Copyright (C) 2000-2010 PhiloSoft Design" +__license__ = "GNU GPL" + + +import sys +import dbus + +def main(): + try: + command = sys.argv[1] + except IndexError: + sys.exit('Usage: %s command' % sys.argv[0]) + + bus = dbus.SessionBus() + remote_object = bus.get_object("name.phdru.XSetBg", "/XSetBg") + iface = dbus.Interface(remote_object, "name.phdru.XSetBg") + + getattr(iface, command)() + +if __name__ == '__main__': + main() diff --git a/xsetbg-dbus-force b/xsetbg-dbus-force new file mode 100755 index 0000000..52f2e2b --- /dev/null +++ b/xsetbg-dbus-force @@ -0,0 +1,2 @@ +#! /bin/sh +exec "$HOME/lib/xsetbg"/xsetbg-dbus-client.py force diff --git a/xsetbg-dbus-restart b/xsetbg-dbus-restart new file mode 100755 index 0000000..c10e812 --- /dev/null +++ b/xsetbg-dbus-restart @@ -0,0 +1,2 @@ +#! /bin/sh +"$HOME/lib/xsetbg"/xsetbg-dbus-stop && exec "$HOME/lib/xsetbg"/xsetbg-dbus-start diff --git a/xsetbg-dbus-start b/xsetbg-dbus-start new file mode 100755 index 0000000..418deb1 --- /dev/null +++ b/xsetbg-dbus-start @@ -0,0 +1,4 @@ +#! /bin/sh + +umask 077 +nice -20 ionice -c3 "$HOME/lib/xsetbg"/xsetbg-dbus.py >/dev/null 2>&1 & diff --git a/xsetbg-dbus-stop b/xsetbg-dbus-stop new file mode 100755 index 0000000..3d2bec8 --- /dev/null +++ b/xsetbg-dbus-stop @@ -0,0 +1,2 @@ +#! /bin/sh +exec "$HOME/lib/xsetbg"/xsetbg-dbus-client.py stop diff --git a/xsetbg-dbus.py b/xsetbg-dbus.py new file mode 100755 index 0000000..386df21 --- /dev/null +++ b/xsetbg-dbus.py @@ -0,0 +1,51 @@ +#! /usr/bin/env python +"""XSetBg (DBus version) + +""" + +__version__ = "$Revision$"[11:-2] +__revision__ = "$Id$"[5:-2] +__date__ = "$Date$"[7:-2] + +__author__ = "Oleg Broytman " +__copyright__ = "Copyright (C) 2000-2010 PhiloSoft Design" +__license__ = "GNU GPL" + +import gobject + +import dbus +import dbus.service +import dbus.mainloop.glib + +from xsetbg import change + + +class XsetBg(dbus.service.Object): + + @dbus.service.method("name.phdru.XSetBg", in_signature='', out_signature='') + def change(self): + change() + + @dbus.service.method("name.phdru.XSetBg", in_signature='', out_signature='') + def force(self): + change(force=True) + + @dbus.service.method("name.phdru.XSetBg", in_signature='', out_signature='') + def stop(self): + mainloop.quit() + + @dbus.service.method("name.phdru.XSetBg", in_signature='', out_signature='') + def stop(self): + mainloop.quit() + + +if __name__ == '__main__': + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + + session_bus = dbus.SessionBus() + name = dbus.service.BusName("name.phdru.XSetBg", session_bus) + object = XsetBg(session_bus, '/XSetBg') + + change(force=True) + mainloop = gobject.MainLoop() + mainloop.run() diff --git a/xsetbg-change b/xsetbg-http-change similarity index 100% rename from xsetbg-change rename to xsetbg-http-change diff --git a/xsetbg-force b/xsetbg-http-force similarity index 100% rename from xsetbg-force rename to xsetbg-http-force diff --git a/xsetbg-http-restart b/xsetbg-http-restart new file mode 100755 index 0000000..81eb21b --- /dev/null +++ b/xsetbg-http-restart @@ -0,0 +1,2 @@ +#! /bin/sh +"$HOME/lib/xsetbg"/xsetbg-http-stop && exec "$HOME/lib/xsetbg"/xsetbg-http-start diff --git a/xsetbg-http-start b/xsetbg-http-start new file mode 100755 index 0000000..03a6cfb --- /dev/null +++ b/xsetbg-http-start @@ -0,0 +1,4 @@ +#! /bin/sh + +umask 077 +nice -20 ionice -c3 "$HOME/lib/xsetbg"/xsetbg-wsgi.py >/dev/null 2>&1 & diff --git a/xsetbg-stop b/xsetbg-http-stop similarity index 100% rename from xsetbg-stop rename to xsetbg-http-stop diff --git a/xsetbg-restart b/xsetbg-restart deleted file mode 100755 index ca35682..0000000 --- a/xsetbg-restart +++ /dev/null @@ -1,2 +0,0 @@ -#! /bin/sh -"$HOME/lib/xsetbg"/xsetbg-stop && exec "$HOME/lib/xsetbg"/xsetbg-start diff --git a/xsetbg-start b/xsetbg-start deleted file mode 100755 index 85e3f1a..0000000 --- a/xsetbg-start +++ /dev/null @@ -1,4 +0,0 @@ -#! /bin/sh - -umask 077 -nice -20 ionice -c3 "$HOME/lib/xsetbg"/xsetbg.py >/dev/null 2>&1 & -- 2.39.2