bltijo

Wifi Signal Watcher

Aug 27th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.60 KB | None | 0 0
  1. #!/usr/bin/perl
  2. # Usage : ./script.perl <ifname> <dB thresold>
  3.  
  4. use strict;
  5. use warnings;
  6.  
  7. my $interface=$ARGV[0];
  8. my $threshold=$ARGV[1];
  9.  
  10. my $delay=1;
  11. my $currentSignal = `nmcli -g SIGNAL  d w list ifname $interface`;
  12. while(1){
  13.         if ($currentSignal < $threshold){
  14.                 my $response=system("zenity --question --ellipsize --text=\"Wifi is under $threshold : $currentSignal\" --ok-label \"Sleep $delay seconds\" --cancel-label \"Turn off\";") >> 8;
  15.                 if ($response == 1){
  16.                         exit(0);
  17.                 }
  18.                 sleep($delay)
  19.         }
  20. }
Add Comment
Please, Sign In to add comment