summaryrefslogtreecommitdiffstats
path: root/draksnapshot-applet
diff options
context:
space:
mode:
Diffstat (limited to 'draksnapshot-applet')
-rwxr-xr-xdraksnapshot-applet26
1 files changed, 26 insertions, 0 deletions
diff --git a/draksnapshot-applet b/draksnapshot-applet
index d1d1a09..bc48a26 100755
--- a/draksnapshot-applet
+++ b/draksnapshot-applet
@@ -29,6 +29,7 @@ use interactive;
use common;
use run_program;
use detect_devices;
+use dbus_object;
use feature 'state';
use Gtk2::Pango;
@@ -70,6 +71,29 @@ my %actions = (
'configure' => { name => N("Configure"), launch => \&configure }
);
+my $hal_dn = 'org.freedesktop.Hal';
+my $hal_manager = "$hal_dn.Manager";
+my $manager_path = '/org/freedesktop/Hal/Manager';
+
+my $dbus = dbus_object::system_bus();
+
+my $do = dbus_object->new($dbus, $hal_dn, $manager_path, $hal_manager);
+
+my $con = $dbus->{connection};
+$con->add_filter(sub {
+ my ($_bus, $msg) = @_;
+ return if $msg->get_member ne 'DeviceAdded';
+ my $hal = $dbus->get_service($hal_dn);
+ my $bool;
+ eval {
+ my $device = $hal->get_object(($msg->get_args_list)[0], "$hal_dn.Device");
+ $bool = $device->QueryCapability('block') && $device->GetProperty('block.is_volume');
+ };
+ go2State($bool ? 'disk_found' : 'okay');
+ 0;
+ });
+$con->add_match("type='signal',interface='$hal_manager'");
+
my $icon = Gtk2::StatusIcon->new;
$icon->signal_connect(popup_menu => sub {
my ($_icon, $button, $time) = @_;
@@ -91,6 +115,8 @@ $SIG{USR2} = 'IGNORE';
$SIG{CHLD} = \&harvester;
run_program::raw({ detach => 1 }, 'ionice', '-p', $$, '-n7');
+
+$do->set_gtk2_watch;
Gtk2->main;
ugtk2::exit(0);