svg_bar 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/bash
  2. #generates bar as a svg-file to stdout
  3. #
  4. #usage:
  5. # svg_bar WIDTH PROGRESS "Text"
  6. #
  7. # WIDTH are are defined number of pixels
  8. # PROGRESS is defined by percent
  9. #
  10. #Sigmund Berglund, dec 2013
  11. #GPL
  12. #read config if exist
  13. [ -s $HOME/.config/ptheme/gtkdialog_active ] && . $HOME/.config/ptheme/gtkdialog_active
  14. [ ! "$SVG_BAR_COLOR_USED" ] && SVG_BAR_COLOR_USED='#006793'
  15. [ ! "$SVG_BAR_COLOR_TOTAL" ] && SVG_BAR_COLOR_TOTAL='#444444'
  16. [ ! "$SVG_BAR_COLOR_TEXT" ] && SVG_BAR_COLOR_TEXT='#bbbbbb'
  17. [ ! "$SVG_BAR_HEIGHT" ] && SVG_BAR_HEIGHT=24
  18. echo '<?xml version="1.1" encoding="UTF-8"?>
  19. <svg height="'$SVG_BAR_HEIGHT'" width="'$1'">
  20. <defs>
  21. <linearGradient id="LGD_02">
  22. <stop style="stop-color:'$SVG_BAR_COLOR_USED';stop-opacity:1" offset="0" />
  23. <stop style="stop-color:'$SVG_BAR_COLOR_USED';stop-opacity:0" offset="1" />
  24. </linearGradient>
  25. <linearGradient id="LG_02"
  26. x1="'$(($2-3))'" y1="10" x2="'$2'" y2="10"
  27. xlink:href="#LGD_02"
  28. gradientUnits="userSpaceOnUse" />
  29. </defs>
  30. <rect style="fill:'$SVG_BAR_COLOR_TOTAL';stroke:#111111;stroke-width:3" width="'$1'" height="'$SVG_BAR_HEIGHT'" x="0" y="0"/>
  31. <rect style="fill:url(#LG_02);" width="'$(($1-3))'" height="'$(($SVG_BAR_HEIGHT-3))'" x="1.5" y="1.5"/>
  32. <path style="fill:none;stroke:#ffffff;stroke-width:3" d="M 0,'$SVG_BAR_HEIGHT' '$1','$SVG_BAR_HEIGHT' M '$1',0 '$1','$SVG_BAR_HEIGHT'"/>
  33. <text
  34. style="fill:'$SVG_BAR_COLOR_TEXT';font-family:Mono;font-size:'$(($SVG_BAR_HEIGHT/2))';text-anchor:middle"
  35. x="'$(($1/2))'" y="'$(($SVG_BAR_HEIGHT*17/24))'">
  36. '$3'
  37. </text>
  38. </svg>'