updated on Thu Jan 26 00:18:00 UTC 2012
[aur-mirror.git] / rfkill-applet / rfkill-applet.pl
blobd3dbf82b1cc12b039a1c0470e5915e75e6f8ba3c
1 #!/usr/bin/env perl
2 #RFKill-Applet (Harvie 2oo9)
4 use strict;
5 use Gtk2 -init;
7 my $rfkill = '/sys/class/rfkill/rfkill*/state';
8 #my $rfkill = '/sys/devices/*/*/*/rfkill/rfkill*/state';
9 my $icon_e = 'gnome-dev-wavelan'; #enabled
10 my $icon_d = 'emblem-unreadable'; #disabled
12 my $statusicon = Gtk2::StatusIcon->new();
13 #$statusicon->signal_connect(activate => sub { Gtk2->main_quit; }); #exit on click...
15 my $state = -1;
16 $SIG{'ALRM'} = sub {
17 my $last = $state;
18 $state = `head -c 1 $rfkill 2> /dev/null`;
19 if($state != $last) {
20 if($state == 1) {
21 $statusicon->set_from_icon_name($icon_e);
22 $statusicon->set_tooltip_text('Radio enabled');
23 } else {
24 $statusicon->set_from_icon_name($icon_d);
25 $statusicon->set_tooltip_text('Radio disabled');
28 alarm(1);
30 alarm(1);
32 Gtk2->main;