#!/usr/bin/env perl
use 5.10.0;
use strict;
use warnings;
use Glib::Object::Introspection;

Glib::Object::Introspection->setup(basename => "GUdev",
                                   version => "1.0",
                                   package => "Glib::UDev");

# FIXME: Glib::UDev::Client->new ([ qw[block usb/usb_interface] ]);
my $client = Glib::Object::new ('Glib::UDev::Client',
                                subsystems => [ 'block', 'usb/usb_interface' ]);
my $dev = $client->query_by_device_file ('/dev/loop0');
say '/dev/loop0:';
say '  subsystem:             ', $dev->get_subsystem ();
say '  devtype:               ', $dev->get_devtype ();
say '  name:                  ', $dev->get_name ();
say '  number:                ', $dev->get_number ();
say '  sysfs_path:            ', $dev->get_sysfs_path ();
say '  driver:                ', $dev->get_driver () // '(none)';
say '  action:                ', $dev->get_action () // '(none)';
say '  seqnum:                ', $dev->get_seqnum ();
say '  device type:           ', $dev->get_device_type ();
say '  device number:         ', $dev->get_device_number ();
say '  device file:           ', $dev->get_device_file ();
say '  device file symlinks:  ', join ', ', @{$dev->get_device_file_symlinks ()};
say '  sysfs attr:            ', join ', ', @{$dev->get_sysfs_attr_as_strv ("stat")};
say '  properties:';
foreach my $key (@{$dev->get_property_keys ()}) {
  say "    ", $key, "=", $dev->get_property ($key);
}
