Skip to content

Instantly share code, notes, and snippets.

@infirit
infirit / gdbus_subclass_unicode_error.py
Created December 11, 2016 16:50
GDBusProxy subclass
from gi.repository import Gio, GLib, GObject
class MyProxy(Gio.DBusProxy):
__gsignals__ = {str('property-changed'): (GObject.SignalFlags.NO_HOOKS, None,
(GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT))
}
def __init__(self, interface_name, obj_path, *args, **kwargs):
super(MyProxy, self).__init__(
g_name="org.bluez",
@infirit
infirit / dbus_async_callbacks.py
Last active October 31, 2021 05:42
dbus-python async_callbacks
import dbus
import dbus.service
from dbus.mainloop.glib import DBusGMainLoop
import time
from gi.repository import GLib
DBusGMainLoop(set_as_default=True)
class MyTestClass(dbus.service.Object):
@infirit
infirit / blueman_2.0_polkit_auth.diff
Created May 5, 2016 10:32
blueman polkit auth changes
diff --git a/blueman/plugins/mechanism/Network.py b/blueman/plugins/mechanism/Network.py
index ab7465f..317a3f6 100644
--- a/blueman/plugins/mechanism/Network.py
+++ b/blueman/plugins/mechanism/Network.py
@@ -53,6 +53,7 @@ class Network(MechanismPlugin):
@dbus.service.method('org.blueman.Mechanism', in_signature="ayays", out_signature="", sender_keyword="caller",
byte_arrays=True)
def EnableNetwork(self, ip_address, netmask, dhcp_handler, caller):
+ self.confirm_authorization(caller, "org.blueman.network.setup")
nc = NetConf.get_default()
@infirit
infirit / bluez_disabled_systemd.patch
Created March 22, 2016 14:47
systemd bluez disabled
diff --git a/blueman/bluez/BlueZInterface.py b/blueman/bluez/BlueZInterface.py
index 366cf17..3bd7be1 100644
--- a/blueman/bluez/BlueZInterface.py
+++ b/blueman/bluez/BlueZInterface.py
@@ -12,17 +12,19 @@ class BlueZInterface(object):
@staticmethod
def get_interface_version():
- if not BlueZInterface.interface_version:
- obj = dbus.SystemBus().get_object('org.bluez', '/')
@infirit
infirit / dbusproxy_subclass.py
Last active January 16, 2016 15:05
dbusproxy subclass
from gi.repository import Gio, GLib, GObject
class TestProxy(Gio.DBusProxy):
__bus = Gio.bus_get_sync(Gio.BusType.SYSTEM)
def __init__(self, name, obj_path, interface):
super(TestProxy, self).__init__(
g_connection=self.__bus,
g_flags=Gio.DBusProxyFlags.NONE,
g_interface_info=None,
g_name=name,
@infirit
infirit / adapter_base_class.py
Created January 12, 2016 19:32
bluez adapter base proxy class
from gi.repository import Gio, GLib, GObject
class BaseProxy(Gio.DBusProxy):
__gsignals__ = {
str('property-changed'): (GObject.SignalFlags.NO_HOOKS,
None,
(GObject.TYPE_PYOBJECT,
GObject.TYPE_PYOBJECT,
GObject.TYPE_PYOBJECT))
}
@infirit
infirit / gdbus_bluez_adapter_test.py
Last active December 6, 2016 15:29
GDBus bluez adapter example
from gi.repository import Gio, GLib, GObject
proxy = Gio.DBusProxy.new_sync(
Gio.bus_get_sync(Gio.BusType.SYSTEM),
Gio.DBusProxyFlags.NONE,
None,
'org.bluez',
'/org/bluez/hci0',
'org.freedesktop.DBus.Properties')
@infirit
infirit / adapter_duplicate_signal.py
Created October 27, 2015 07:26
debugging blueman-adapters
import blueman.bluez as Bluez
import os
from gi.repository import Gtk
def on_property_changed(adapter, name, value, path):
print(path)
print(name)
print(value)
def on_adapter_added(manager, adapter_path):
@infirit
infirit / fade_box_window.py
Created August 14, 2015 19:29
Fade-in pixbuf box
#!/usr/bin/python
from gi.repository import Gtk, GLib, Gdk
import cairo
class FadeBoxWindow(Gtk.Window):
def __init__(self):
super(FadeBoxWindow, self).__init__()
self.init_ui()
@infirit
infirit / notification_test.py
Created August 5, 2015 15:53
blueman notification test
#!/usr/bin/python
from blueman.gui.Notification import Notification
from blueman.Functions import get_icon
from gi.repository import Gdk, Gtk
class StatusIconMock:
def get_geometry(self):
screen = Gdk.Screen.get_default()
rect = Gdk.Rectangle()