daily pastebin goal
57%
SHARE
TWEET

traybarscript.zsh Aeva

a guest Apr 25th, 2012 226 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/zsh
  2. # ~/.xmonad/traybarscript.zsh
  3. ## Variables ##
  4. # Date & Time
  5. DATE_FORMAT='%a, %d/%m/%Y'
  6. TIME_FORMAT='%R'
  7.  
  8. # Intervals
  9. BATIVAL=30
  10. INTERVAL=30
  11. IVAL=60
  12. VOLIVAL=60
  13.  
  14. # Counters
  15. BATCOUNTER=$BATIVAL
  16. DATECOUNTER=$IVAL
  17. TIMECOUNTER=$IVAL
  18. VOLCOUNTER=$VOLIVAL
  19.  
  20. # Text
  21. SEP="|"
  22.  
  23. ## Functions ##
  24. fbat()
  25. {
  26.         BAT_PERC=`acpi -b | awk '{print $4}'`;
  27.         print "${BAT_PERC%,}"
  28. }
  29. fgov()
  30. {
  31.         CPU_GOV=`cpufreq-info -c 0 | awk '/speed/ {print $3}'`
  32.         CPU_GOV=${CPU_GOV%"\""}
  33.         CPU_GOV=${CPU_GOV#"\""}
  34.         print "(${CPU_GOV})"
  35. }
  36. ficontype()
  37. {
  38.         BAT_ICON_TYPE=`acpi -a | awk '{print $3}'`;
  39.         print "${BAT_ICON_TYPE}"
  40. }
  41. fvolume()
  42. {
  43.         VOLUME=`amixer get "Master" | grep "dB" | awk '{print $4}'`
  44.         VOLUME=${VOLUME%"]"}
  45.         VOLUME=${VOLUME#"["}
  46.         print "${VOLUME}"
  47. }
  48. fdate() { date +$DATE_FORMAT }
  49. ftime() { date +$TIME_FORMAT }
  50.  
  51. while true; do
  52.     if [ $VOLCOUNTER -ge $VOLIVAL ]; then
  53.         VOL_ICON='^i(/home/lilith/.dzen/xbm8x8/spkr_01.xbm)'
  54.         TBVOL=$(fvolume)
  55.         VOLCOUNTER=0
  56.     fi
  57.  
  58.     if [ $BATCOUNTER -ge $BATIVAL ]; then
  59.         BAT_IT=$(ficontype)
  60.         if [[ "$BAT_IT" == "off-line" ]]; then
  61.         BAT_ICON='^i(/home/lilith/.dzen/dzen_bitmaps/battery.xbm)'
  62.         else
  63.         BAT_ICON='^i(/home/lilith/.dzen/xbm8x8/ac.xbm)'
  64.         fi
  65.         TBBAT=$(fbat)
  66.         TBGOV=$(fgov)
  67.         BATCOUNTER=0
  68.     fi
  69.  
  70.     if [ $DATECOUNTER -ge $IVAL ]; then
  71.         TBDATE=$(fdate)
  72.         DATECOUNTER=0
  73.     fi
  74.  
  75.     if [ $TIMECOUNTER -ge $IVAL ]; then
  76.         TBTIME=$(ftime)
  77.         TIMECOUNTER=0
  78.     fi
  79.  
  80.     print " $SEP $VOL_ICON $TBVOL $SEP $BAT_ICON $TBBAT $TBGOV $SEP $TBDATE $SEP $TBTIME "
  81.  
  82.     VOLCOUNTER=$((VOLCOUNTER+30))  
  83.     BATCOUNTER=$((BATCOUNTER+30))
  84.     DATECOUNTER=$((DATECOUNTER+30))
  85.     TIMECOUNTER=$((TIMECOUNTER+30))
  86.  
  87.     sleep $INTERVAL
  88. done
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top