Guest User

Untitled

a guest
Dec 3rd, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.84 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3.  
  4. output="<txt>"
  5. next="|||||||||"
  6.  
  7. secondary_color="#5294e2"
  8. secondary_color="#4084d6"
  9. warning_color="#fea962"
  10. error_color="#FF4136"
  11.  
  12. ##########################
  13. # MPD
  14. ##########################
  15.  
  16. # if i try display title with '&' in name genmon stops updating
  17. mpd_title=$(mpc | head -1 | sed 's/&/and/g')
  18. mpd_status=$(mpc | head -2 | tail -1)
  19.  
  20. if grep -q "playing" <<< "$mpd_status" ; then
  21. output="<click>mpc toggle</click>$output<span font=\"FontAwesome 9\" weight=\"heavy\" fgcolor=\"$secondary_color\"><sup>  </sup></span> $mpd_title$next"
  22. # output="<img>/usr/share/icons/ArcPaper/actions/16/gtk-media-pause.png</img><click>mpc toggle</click>$output<span font=\"FontAwesome 9\" weight=\"heavy\" fgcolor=\"$secondary_color\"><sup>  </sup></span> $mpd_title$next"
  23. elif grep -q "paused" <<< "$mpd_status" ; then
  24. output="<img>/usr/share/icons/ArcPaper/actions/16/gtk-media-play-ltr.png</img><click>mpc toggle</click>$output<span font=\"FontAwesome 9\" weight=\"heavy\" fgcolor=\"$secondary_color\"><sup>  </sup></span><span fgcolor=\"$warning_color\"> $mpd_title</span>$next"
  25. fi
  26.  
  27.  
  28.  
  29. ##########################
  30. # Battery
  31. ##########################
  32.  
  33. if [ $(ls /sys/class/power_supply | grep BAT | wc -l) -gt 0 ]; then
  34. battery_directory="/sys/class/power_supply/"$(ls /sys/class/power_supply | grep BAT | head -1)"/"
  35. energy_now=$(<$battery_directory"/charge_now")
  36. energy_full=$(<$battery_directory"/charge_full")
  37. battery_color=""
  38. charge=$(($energy_now*100))
  39. charge=$(($charge/$energy_full))
  40.  
  41. # if [ "90" -gt "$charge" ]; then
  42. # battery_color="color=\"da2818\""
  43. # output=$output"DSADAS"
  44. # fi
  45.  
  46. status=$(<$battery_directory"/status")
  47. charge="<span font=\"SFNS Text Bold, FontAwesome 9\" weight=\"heavy\" fgcolor=\"$secondary_color\"><sup> </sup></span> "$charge"%"
  48. output="$output$charge$next"
  49. fi
  50.  
  51.  
  52.  
  53. ##########################
  54. # RAM
  55. ##########################
  56. freememory=$(free | tail -2 | head -1 | awk '{print $3/$2 * 100.0}' | awk '{printf("%d\n",$1 + 0.5)}' )
  57.  
  58. if (( $freememory > 80 )); then
  59. freememory="<span weight=\"heavy\" fgcolor=\"$error_color\" font=\"FontAwesome 9\"><sup> </sup></span> $freememory%"
  60. elif (( $freememory > 50 )); then
  61. freememory="<span weight=\"heavy\" fgcolor=\"$warning_color\" font=\"FontAwesome 9\"><sup> </sup></span> $freememory%"
  62. else
  63. freememory="<span weight=\"heavy\" fgcolor=\"$secondary_color\" font=\"FontAwesome 9\"><sup> </sup></span> $freememory%"
  64. fi
  65.  
  66. output="$output$freememory$next"
  67.  
  68. ##########################
  69. # CPU
  70. ##########################
  71.  
  72. cpu_usage=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage }' | awk '{printf("%d\n",$1 + 0.5)}' )
  73. if (( $cpu_usage > 80 )); then
  74. cpu_usage="<span weight=\"heavy\" fgcolor=\"$error_color\" font=\"FontAwesome 9\"><sup> </sup></span> $cpu_usage%"
  75. elif (( $cpu_usage > 40 )); then
  76. cpu_usage="<span weight=\"heavy\" fgcolor=\"$warning_color\" font=\"FontAwesome 9\"><sup> </sup></span> $cpu_usage%"
  77. else
  78. cpu_usage="<span weight=\"heavy\" fgcolor=\"$secondary_color\" font=\"FontAwesome 9\"><sup> </sup></span> $cpu_usage%"
  79. fi
  80.  
  81. output="$output$cpu_usage$next"
  82.  
  83. ##########################
  84. # HDD
  85. ##########################
  86.  
  87. hdd_free=$(df --output=avail -h / | tail -n 1 | tr -d ' ')
  88. if [[ $hdd_free == *"G"* ]]
  89. then
  90. hdd_free=$(echo $hdd_free | sed 's/G/ GB/g')
  91. fi
  92. if [[ $hdd_free == *"M"* ]]
  93. then
  94. hdd_free=$(echo $hdd_free | sed 's/M/ MB/g')
  95. fi
  96. hdd_free="<span weight=\"heavy\" fgcolor=\"$secondary_color\" font=\"FontAwesome 9\"><sup> </sup></span> "$hdd_free
  97.  
  98. output="$output$hdd_free$next"
  99.  
  100. ##########################
  101. # DATE
  102. ##########################
  103.  
  104. date_without_month=$(date +"%H:%M, %d")
  105.  
  106. month=$(date +"%m")
  107. set_month_roman=false
  108.  
  109.  
  110. if $set_month_roman
  111. then
  112. case "$month" in
  113. "01") month="I" ;;
  114. "02") month="II" ;;
  115. "03") month="III" ;;
  116. "04") month="IV" ;;
  117. "05") month="V" ;;
  118. "06") month="VI" ;;
  119. "07") month="VII" ;;
  120. "08") month="VIII" ;;
  121. "09") month="IX" ;;
  122. "10") month="X" ;;
  123. "11") month="XI" ;;
  124. "12") month="XII" ;;
  125. *) month="XD"
  126. esac
  127. else
  128. case "$month" in
  129. "01") month="stycznia" ;;
  130. "02") month="lutego" ;;
  131. "03") month="marca" ;;
  132. "04") month="kwietnia" ;;
  133. "05") month="maja" ;;
  134. "06") month="czerwca" ;;
  135. "07") month="lipca" ;;
  136. "08") month="sierpnia" ;;
  137. "09") month="września" ;;
  138. "10") month="października" ;;
  139. "11") month="listopada" ;;
  140. "12") month="grudnia" ;;
  141. *) month="nietzschego"
  142. esac
  143. fi
  144.  
  145. #output="$output$date_without_month $month$next"
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152. output=$(echo $output | sed 's/'$next'/ • /g')
  153. output=${output::-7}"</txt>"
  154.  
  155.  
  156.  
  157. echo -e "$output"
Advertisement
Add Comment
Please, Sign In to add comment