Advertisement
Guest User

Untitled

a guest
Jul 29th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.84 KB | None | 0 0
  1. #!/bin/bash
  2. export DISPLAY=:0.0
  3. # Location of acpi files.
  4. path="/proc/acpi/battery/BAT0"
  5. xtrapath="/home/hkon/.thumbnails/Awesome/bat/sound"
  6. full=`cat $path/info|grep 'last full capacity'|awk -F: '{print $2}'|awk -Fm '{print $1}'`
  7. current=`cat $path/state|grep 'remaining capacity'|awk -F: '{print $2}'|awk -Fm '{print $1}'`
  8. state=$(( current * 100 / $full))
  9. charstate=`cat $path/state|sed '1,2d'|sed '2,4d'|sed 's/charging//'|sed 's/state://'|tr -d " "`
  10.  
  11. if [ "$charstate" = "discharging" ]
  12.      then
  13.  
  14. if [[ "$state" -lt "90" && "$state" -gt "75" ]]
  15.     then
  16. notify-send " " -i /home/hkon/.thumbnails/Awesome/bat/75.png
  17. mplayer $xtrapath/75.wav
  18. fi
  19. if [[ "$state" -lt "75" && "$state" -gt "60" ]]
  20.     then
  21. notify-send " " -i /home/hkon/.thumbnails/Awesome/bat/60.png
  22. mplayer $xtrapath/60.wav
  23. fi
  24. if [[ "$state" -lt "60" && "$state" -gt "45" ]]
  25.     then
  26. notify-send " " -i /home/hkon/.thumbnails/Awesome/bat/45.png
  27. mplayer $xtrapath/45.wav
  28. fi
  29. if [[ "$state" -lt "45" && "$state" -gt "30" ]]
  30.     then
  31. notify-send " " -i /home/hkon/.thumbnails/Awesome/bat/30.png
  32. mplayer $xtrapath/30.wav
  33. fi
  34. if [[ "$state" -lt "30" && "$state" -gt "15" ]]
  35.     then
  36. notify-send " " -i /home/hkon/.thumbnails/Awesome/bat/15.png
  37. mplayer $xtrapath/15.wav
  38. fi
  39. if [[ "$state" -lt "15" && "$state" -gt "10" ]]
  40.     then
  41. notify-send " " -i /home/hkon/.thumbnails/Awesome/bat/10.png
  42. mplayer $xtrapath/10.wav
  43. fi
  44. if [ "$state" -lt "10" ]
  45.     then
  46. notify-send " " -i /home/hkon/.thumbnails/Awesome/bat/plugpray.png
  47. mplayer $xtrapath/plugpray.wav
  48. fi
  49. fi
  50.  
  51. if [ "$charstate" = "charged" ]
  52.     then
  53. notify-send " " -i /home/hkon/.thumbnails/Awesome/bat/charged.png
  54. mplayer $xtrapath/charged.wav
  55. fi
  56. if [ "$charstate" = "charging" ]
  57.     then
  58. notify-send " " -i /home/hkon/.thumbnails/Awesome/bat/charging.png
  59. mplayer $xtrapath/charging.wav
  60. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement