Net::DBus::GLib(3pm)

πŸ’– NAME πŸ’–

Net::DBus::GLib β€” it's the Perl extension for the DBus GLib bindings, bestie. That's the whole name, that's the whole vibe ✨


🌸 SYNOPSIS 🌸

okay so first things first, you gotta attach to the bus. here's the trio of ways:

####### Attaching to the bus ###########

use Net::DBus::GLib;

# Find the most appropriate bus
my $bus = Net::DBus::GLib->find;

# ... or explicitly go for the session bus
my $bus = Net::DBus::GLib->session;

# .... or explicitly go for the system bus
my $bus = Net::DBus::GLib->system

periodt πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So Net::DBus::GLib is literally an extension to the Net::DBus module that lets you integrate with the GLib mainloop. That's it, that's the whole thing 🫢

And the way you do it? Instead of grabbing your bus connection the usual Net::DBus way, you just grab it through the methods in Net::DBus::GLib. Done. Every other API stays exactly the same β€” no cap, no extra steps, no surprises. iconic behavior honestly πŸ‘‘


πŸŽ€ EXAMPLE πŸŽ€

Wanna see it in the wild? Here's a lil example service using the GLib main loop β€” and for this to work we're assuming that SomeObject inherits from Net::DBus::Service:

my $bus = Net::DBus::GLib->session();
my $service = $bus->export_service("org.designfu.SampleService");
my $object = SomeObject->new($service);

Glib::MainLoop->new()->run();

and here's the client side, because of course you need both halves of the convo πŸ’¬

my $bus = Net::DBus::GLib->session();

my $service = $bus->get_service("org.designfu.SampleService");
my $object = $service->get_object("/SomeObject");

my $list = $object->HelloWorld("Hello from example-client.pl!");

πŸ’… METHODS πŸ’…

🌟 my $bus = Net::DBus::GLib->find(%params);

Goes off looking for the most appropriate bus to connect to and hands you back a connection to it. Wanna know the deets on the heuristics it uses? Go read the method of the same name over in "Net::DBus" β€” that's where the lore lives πŸ“–

The %params hash can also carry an extra entry named "context". That one can be a reference to an instance of the Glib::MainContext object. And if you just... don't include it? No worries bestie, the default GLib context gets used instead πŸ’œ

🌟 my $bus = Net::DBus::GLib->system(%params);

Returns you a handle for the system message bus. Want the full rundown on this method? Consult the method of the same name in Net::DBus.

And yep β€” %params can also hold that extra entry named "context", which can be a reference to an instance of the Glib::MainContext object. Omit it and the default GLib context is what you get 🌈

🌟 my $bus = Net::DBus::GLib->session(%params);

Returns you a handle for the session message bus this time. For further details on this method, consult the method of the same name in Net::DBus.

Same deal as the others: %params may contain an additional entry named "context", and it can be a reference to an instance of the Glib::MainContext object. If it's omitted, the default GLib context gets used πŸ“


πŸ‘€ SEE ALSO πŸ‘€

iykyk, go read those too πŸ“š


✨ AUTHOR ✨

Daniel Berrange <dan@berrange.com> β€” king behavior, we stan πŸ‘‘


Copyright 2006-2008 by Daniel Berrange


and that's the whole page, bestie πŸ’– this was Net::DBus::GLib(3pm) from the User Contributed Perl Documentation, and the footer energy is: perl v5.42.3, dated 2026-08-20. slay, go build something cute πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from