1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #!/bin/bash
- #generates bar as a svg-file to stdout
- #
- #usage:
- # svg_bar WIDTH PROGRESS "Text"
- #
- # WIDTH are are defined number of pixels
- # PROGRESS is defined by percent
- #
- #Sigmund Berglund, dec 2013
- #GPL
- #read config if exist
- [ -s $HOME/.config/ptheme/gtkdialog_active ] && . $HOME/.config/ptheme/gtkdialog_active
- [ ! "$SVG_BAR_COLOR_USED" ] && SVG_BAR_COLOR_USED='#006793'
- [ ! "$SVG_BAR_COLOR_TOTAL" ] && SVG_BAR_COLOR_TOTAL='#444444'
- [ ! "$SVG_BAR_COLOR_TEXT" ] && SVG_BAR_COLOR_TEXT='#bbbbbb'
- [ ! "$SVG_BAR_HEIGHT" ] && SVG_BAR_HEIGHT=24
- echo '<?xml version="1.1" encoding="UTF-8"?>
- <svg height="'$SVG_BAR_HEIGHT'" width="'$1'">
- <defs>
- <linearGradient id="LGD_02">
- <stop style="stop-color:'$SVG_BAR_COLOR_USED';stop-opacity:1" offset="0" />
- <stop style="stop-color:'$SVG_BAR_COLOR_USED';stop-opacity:0" offset="1" />
- </linearGradient>
- <linearGradient id="LG_02"
- x1="'$(($2-3))'" y1="10" x2="'$2'" y2="10"
- xlink:href="#LGD_02"
- gradientUnits="userSpaceOnUse" />
- </defs>
- <rect style="fill:'$SVG_BAR_COLOR_TOTAL';stroke:#111111;stroke-width:3" width="'$1'" height="'$SVG_BAR_HEIGHT'" x="0" y="0"/>
- <rect style="fill:url(#LG_02);" width="'$(($1-3))'" height="'$(($SVG_BAR_HEIGHT-3))'" x="1.5" y="1.5"/>
- <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'"/>
- <text
- style="fill:'$SVG_BAR_COLOR_TEXT';font-family:Mono;font-size:'$(($SVG_BAR_HEIGHT/2))';text-anchor:middle"
- x="'$(($1/2))'" y="'$(($SVG_BAR_HEIGHT*17/24))'">
- '$3'
- </text>
- </svg>'
|