1. #!/bin/bash
  2.  
  3.  
  4. # status.sh by SkyZ
  5.  
  6.  
  7. # Conky dans la statusbar
  8. # conky | while read -r; do wmfs -s "$REPLY"; done
  9.  
  10. # Statusbar normal
  11.  
  12.  
  13. # Date and Time est juste
  14. DATE=`date +"%a %e %b"`
  15. TIME=`date +"%H:%M"`
  16. ###
  17.  
  18. # Moc est juste
  19. if [ -z $(pidof mocp) ]; then # On vérifie si moc est lancé
  20. moc="[ Music on Console n'est pas lancé ]"
  21. else
  22. songtitle="`mocp -i | grep 'SongTitle:' | sed -e 's/^.*: //'`"
  23. artist="`mocp -i | grep 'Artist:' | sed -e 's/^.*: //'`"
  24. currenttime="`mocp -i | grep 'CurrentTime:' | sed -e 's/^.*: //'`"
  25. totaltime="`mocp -i | grep 'TotalTime:' | sed -e 's/^.*: //'`"
  26. state="`mocp -i | grep 'State:' | sed -e 's/^.*: //'`"
  27. filetitle="`mocp -i | grep 'Title:'`"
  28. if [ -z $filetitle ]; then
  29. # On vérifie si une piste est en cours d'écoute
  30. moc="[ Aucune piste en cours d'écoute ]"
  31. else
  32. if [ -z $artist ]; then # Si une piste est en cours d'écoute, on vérifie que le titre et le nom de l'artiste sont connus
  33. artist="Inconnu"
  34. fi
  35. if [ -z $songtitle ]; then
  36. songtitle="Inconnu"
  37. fi
  38. if [ "$state" == "PLAY" ]; then # Si une piste est en cours d'écoute, on vérifie si elle est en pause
  39. playing1="$color Titre : $normal$songtitle"
  40. playing2="$color Artiste : $normal$artist"
  41. playing3="$currenttime"
  42. playing4="$totaltime"
  43. moc="[ $playing1 $playing2 ($playing3$color/$normal$playing4) ]"
  44. else
  45. playing1="$color Titre : $normal$songtitle"
  46. playing2="$color Artiste : $normal$artist"
  47. playing3="$currenttime"
  48. playing4="$totaltime"
  49. moc="[ $playing1 $playing2 ($playing3$color/$normal$playing4 -$color Pause $normal) ]"
  50. fi
  51. fi
  52. fi
  53.  
  54. #}
  55. if [ $state == PLAY ]
  56. then
  57. MOC="$artist - $songtitle"
  58. else
  59. MOC=" "
  60. fi
  61. ###
  62.  
  63. # CPU est juste
  64. CPU=`eval $(awk '/^cpu /{print "previdle=" $5 "; prevtotal=" $2+$3+$4+$5 }' /proc/stat); sleep 0.4; eval $(awk '/^cpu /{print "idle=" $5 "; total=" $2+$3+$4+$5 }' /proc/stat); intervaltotal=$((total-${prevtotal:-0})); echo "$((100*( (intervaltotal) - ($idle-${previdle:-0}) ) / (intervaltotal) ))%"`
  65. ###
  66.  
  67. # Temperature est juste
  68. TEMP=`acpi -t | awk 'NR == 1 {print $4}'`;
  69. ###
  70.  
  71. # Volume est juste
  72. VOL=`amixer | grep "Master" -A 5 | grep -o "\[.*%" | sed "s/\[//"`
  73. ###
  74.  
  75. # Batterie est juste et en cours
  76. BAT0=`acpi -b | awk '{print $4}'`
  77.  
  78. etatbat=`acpi -b | awk '{print $3}'`
  79.  
  80. if [ $etatbat = "Discharging," ]; then
  81. BAT="$BAT0 D"
  82. elif [ $etatbat = "Charging," ]; then
  83. BAT="$BAT0 C"
  84. elif [ $etatbat = "Full," ]; then
  85. BAT="$BAT0 F"
  86. else
  87. BAT="$BAT0"
  88. fi
  89. ###
  90.  
  91. # Disk usage root
  92. DUroot=`df -h | awk 'NR == 2 {print $3, $5}'`
  93. DUhome=`df -h | awk 'NR == 6 {print $3, $5}'`
  94. ###
  95.  
  96. # Memoire utilise
  97. MEM1=`free -m | awk '/buffers\/cache/{print $3}'`
  98. MEM2=40 # for 4go, 20 for 2go
  99. MEM=`echo "$MEM1 / $MEM2" | bc`
  100. ###
  101.  
  102. # Wifi faux
  103. # WIFI=`cat /sys/class/net/wlan0/wireless/link`
  104.  
  105. # \i[1476;2;14;14;/home/stephen/.config/wmfs/icons/time.png]\
  106. # \i[1229;2;15;15;/home/stephen/.config/wmfs/icons/mpd.png]\
  107. # `25dw \i[1483;2;14;14;/home/stephen/.config/wmfs/icons/cal.png]\
  108. # `26dw
  109.  
  110. # Afichage
  111. wmfs -s "Mus. $MOC | Cpu. $CPU | Mem. $MEM% | Temp. $TEMP C | Root. $DUroot | Home. $DUhome | Bat. $BAT | Vol. $VOL | Date. $DATE $TIME "