Advertisement
Guest User

Untitled

a guest
May 6th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.64 KB | None | 0 0
  1. #!/bin/perl
  2.  
  3. $output = `acpi`;
  4. @output = split(/ /, $output);
  5. $last = "";
  6.  
  7. # print($output[3]);
  8. while (1) {
  9.   $output = `acpi`;
  10.   @output = split(/ /, $output);
  11.   #print($output[2]);
  12.   if ($output[2] eq "Discharging,") {
  13.     $bat = $output[3];
  14.     #print("DECH");
  15.     if ($bat eq "90%," && $last ne $bat) {
  16.       `aplay /home/$HOME/Music/90.wav`;
  17.       $last = $bat;
  18.     } elsif ($bat eq "50%," && $last ne $bat) {
  19.       `aplay /home/$HOME/Music/50.wav`;
  20.       $last = $bat;
  21.     } elsif ($bat eq "10%," && $last ne $bat) {
  22.       `aplay /home/$HOME/Music/10.wav`;
  23.       $last = $bat;
  24.     }
  25.   } else {
  26.     $last = "";
  27.   }
  28.   sleep(5)
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement