| 1 | #!/usr/bin/env perl |
| 2 | #RFKill-Applet (Harvie 2oo9) |
| 3 | |
| 4 | use strict; |
| 5 | use Gtk2 -init; |
| 6 | |
| 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 |
| 11 | |
| 12 | my $statusicon = Gtk2::StatusIcon->new(); |
| 13 | #$statusicon->signal_connect(activate => sub { Gtk2->main_quit; }); #exit on click... |
| 14 | |
| 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'); |
| 26 | } |
| 27 | } |
| 28 | alarm(1); |
| 29 | }; |
| 30 | alarm(1); |
| 31 | |
| 32 | Gtk2->main; |
| 33 | |
| 34 | |