Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

net::dbus example

by didiw (Initiate)
on Aug 14, 2019 at 12:12 UTC ( #11104448=perlquestion: print w/replies, xml ) Need Help??

didiw has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I want to write a script reacting on specific ipower events on dbus. Can someone please provide an example without polling dbus all the time=.

I thought using net::dbus::reactor and the add_read method seems the way to go, but I have no idea, what to do with the fd variable that is the first argument to add_read, because it is not explanined in the man page.

I also will stick to another other method, if it is working.

Anyway, I would like to have an example of what this file descriptor is used for.

Thanks in advance

Didiw

Replies are listed 'Best First'.
Re: net::dbus example
by daxim (Curate) on Aug 16, 2019 at 10:41 UTC
    another other method, if it is working
    Run dbus-monitor and it will react for you. Small stand-alone example:
    dbus-monitor --system "type='signal',sender='org.freedesktop.UDisk +s2',interface='org.freedesktop.DBus.Properties'" | perl -lne' if (/^\s+ ([[:xdigit:]]{2} \s)+/msx) { $r .= $_; } elsif (/\s+\]/ && $r) { my $mount = join "", map { chr hex $_ } grep { !!$_ && $_ +ne "00" } split /\s+/, $r; system "xdg-open", $mount; $r = ""; } '

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11104448]
Approved by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2020-10-24 00:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (242 votes). Check out past polls.

    Notices?