| 1 | #!/usr/bin/env perl |
| 2 | #RFKill-Applet (Harvie 2oo9) |
| 3 | |
| 4 | use strict; |
| 5 | use threads; |
| 6 | use Gtk2 -init; |
| 7 | |
| 8 | my $rfkill = '/sys/class/rfkill/rfkill*/state'; |
| 9 | #my $rfkill = '/sys/devices/*/*/*/rfkill/rfkill*/state'; |
| 10 | my $icon_e = 'gnome-dev-wavelan'; #enabled |
| 11 | my $icon_d = 'emblem-unreadable'; #disabled |
| 12 | |
| 13 | my $statusicon = Gtk2::StatusIcon->new(); |
| 14 | #$statusicon->signal_connect(activate => sub { Gtk2->main_quit; }); #exit on click... |
| 15 | |
| 16 | my $state = -1; |
| 17 | if(fork()) { |
| 18 | Gtk2->main; |
| 19 | } else { |
| 20 | #my $thr = threads->new(sub { |
| 21 | while(1) { |
| 22 | #sleep(1); |
| 23 | my $last = $state; |
| 24 | $state = `head -c 1 $rfkill 2> /dev/null`; |
| 25 | if($state != $last) { |
| 26 | if($state >= 1) { |
| 27 | $statusicon->set_from_icon_name($icon_e); |
| 28 | $statusicon->set_tooltip_text('Radio enabled'); |
| 29 | } else { |
| 30 | $statusicon->set_from_icon_name($icon_d); |
| 31 | $statusicon->set_tooltip_text('Radio disabled'); |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | #}); |
| 36 | } |
| 37 | |
| 38 | print "RRR"; |
| 39 | |
| 40 | |