I'd like to use a simple Perl script to make some configurations every time I connect e.g. my bluetooth headset. I tried using Net::DBus, but my OS/DE (Fedora 17, GNOME3) doesn't use HAL anymore.
I really don't want to install HAL just for this, so what do I do? My ideas so far:
org.freedesktop.Hal
. Problem: I cannot find the corresponding service, org.freedesktop.UDisks
only seems to monitor disks (duh). Does UDev even send DBus messages for other devices and if not, can I configure it to do so?Or I may be completely off and UDev isn't even what I need. Neither the docs nor Google were really helpful regarding that matter. A workaround would be if anyone knows how to get GNOME3 to switch audio output to a newly connected bluetooth headset per default, but I'd like to learn scripting stuff like that anyway.
Thanks in advance for any pointers!
A.
PS: By the way, Google&Co. claim that UDev gets the devices and sends a message to HAL, which in turn notifies DBus. That is most definitely not the case since HAL isn't even in the Fedora Repos aymore.
You can use Udev::FFI (cpanm Udev::FFI)
For example:
use Udev::FFI;
my $udev = Udev::FFI->new() or
die "Can't create udev context.";
my $monitor = $udev->new_monitor() or
die "Can't create udev monitor.";
$monitor->filter_by_subsystem_devtype('usb', 'usb_device');
$monitor->start() or die "Can't start monitor.";
for(;;) {
if(defined(my $device = $monitor->poll())) {
my $action = $device->get_action();
if($action eq 'add') {
#work with $device
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With