stefano-m / lua-dbus_proxy

Simple API around GLib's GIO:GDBusProxy built on top of lgi
https://stefano-m.github.io/lua-dbus_proxy/
Apache License 2.0
17 stars 7 forks source link

[question] How to set DO_NOT_AUTO_START? #13

Closed Freed-Wu closed 2 weeks ago

Freed-Wu commented 1 month ago

Comes from https://github.com/ibus/ibus/issues/2669

TIA!

stefano-m commented 1 month ago

You can pass the flags parameter when creating a proxy object. See https://stefano-m.github.io/lua-dbus_proxy/#Proxy:new

Probably something like:

local lgi = require("lgi")

p = require 'dbus_proxy'
proxy = p.Proxy:new(
  {
    bus = p.Bus.SESSION,
    name = "org.freedesktop.IBus",
    interface = "org.freedesktop.IBus",
    path = "/org/freedesktop/IBus",
    flags = lgi.Gio.DBusProxyFlags.DO_NOT_AUTO_START
  }
)
Freed-Wu commented 1 month ago

How to assign bus address? I try

proxy0 = p.Proxy:new(
  {
    bus = p.Bus["unix:path=/home/wzy/.cache/ibus/dbus-c2RX3vlC,guid=d8c2b7e5b01276d5bcc582f666ae1289"],
    name = "org.freedesktop.IBus",
    interface = "org.freedesktop.IBus",
    path = "/org/freedesktop/IBus",
    flags = lgi.Gio.DBusProxyFlags.DO_NOT_AUTO_START
  }
)

It will give me

(process:979743): GLib-GIO-CRITICAL **: 12:38:38.335: g_dbus_connection_signal_subscribe: assertion 'sender == NULL || (g_dbus_is_name (sender) && (connection->flags & G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION))' failed

(process:979743): GLib-GIO-CRITICAL **: 12:38:38.335: g_dbus_connection_signal_subscribe: assertion 'sender == NULL || (g_dbus_is_name (sender) && (connection->flags & G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION))' failed

Timeout was reached

Stack trace:
        #0 [C]: in function ?
        #1 [C]: in function 'error'
        #2 /home/wzy/.local/share/lua/5.1/dbus_proxy/_proxy.lua:584: in function 'new'
Freed-Wu commented 2 weeks ago

I doubt it is because https://github.com/stefano-m/lua-dbus_proxy/blob/master/src/dbus_proxy/_bus.lua#L34 pass None to Connection Flags. https://github.com/ibus/ibus/issues/2669#issuecomment-2308008274

Freed-Wu commented 2 weeks ago

Change Gio.DBusConnectionFlags.NONE to Gio.DBusConnectionFlags.AUTHENTICATION_CLIENT + Gio.DBusConnectionFlags.MESSAGE_BUS_CONNECTION can solve problem.

stefano-m commented 2 weeks ago

Hi!

Your original question was about how to add flags to a proxy object, which I showed you how to do.

I understand from your latest messages that in addition to that, you need to be able to set flags on a Bus object.

It would be best if we discussed separate topics on separate issues rather than renaming old ones.

Please create a new issue explaining with as much detail as possible:

  1. what you are trying to achieve
  2. what problem you are having
  3. where you think the problem may be
  4. how you think the problem can be solved
  5. what solution you suggest
  6. what tests you ran and what results you got

This will help keeping issues clean and separate.

Thanks!