[download]

local/bin/filvice

   1 #!/bin/bash
   2 
   3 adjust(){ # {{{
   4     local r=$(printf %d 0x${1:1:2} | awk -v m=$2 '{ print int($1 * m) }')
   5     local g=$(printf %d 0x${1:3:2} | awk -v m=$2 '{ print int($1 * m) }')
   6     local b=$(printf %d 0x${1:5:2} | awk -v m=$2 '{ print int($1 * m) }')
   7 
   8     (( r < 0 )) && r=0
   9     (( g < 0 )) && g=0
  10     (( b < 0 )) && b=0
  11 
  12     (( r > 255 )) && r=255
  13     (( g > 255 )) && g=255
  14     (( b > 255 )) && b=255
  15 
  16     printf '#%02x%02x%02x\n' $r $g $b
  17 } # }}}
  18 source ~/.theme/sh
  19 
  20 f=~/.cache/${0##*/}
  21 r=$(xrandr  | awk '/\*/ { print $1 }')
  22 s=$(echo $r | awk -F x '{ print $2 / 5 }')
  23 
  24 black1=$(adjust $background 1.33)
  25 black2=$(adjust $background 1.66)
  26 
  27 [[ $# == 0   ]] && echo > $f
  28 [[ $1 == -r  ]] && set -- $(< $f)
  29 [[ $1 == -ll ]] && background=$black2 && echo "$@" > $f
  30 [[ $1 == -l  ]] && {
  31     [[ ! $2 ]] && background=$black1 ||
  32     background=$(adjust $background $2)
  33 } && echo "$@" > $f
  34 
  35 cat > $f.svg <<SVG # {{{
  36 <svg width="95.06mm" height="216.6mm" viewBox="0 0 336.8 738.7" xmlns="http://www.w3.org/2000/svg">
  37   <path d="m336.6 704.5a168.4 34.78 0 0 1 -168.4 34.5 168.4 34.78 0 0 1 -168.39-34.5 168.4 34.78 0 0 1 168.39-35 168.4 34.78 0 0 1 168.4 35z" fill-opacity=".2" stroke-linecap="round" stroke-width="2" transform="translate(0, 10)"/>
  38   <path d="m256.1 529.3c0 78.5-31.4 94.1-99.9 94.1-68.53 0-74.28-19.3-74.28-97.8 0-78.4 14.12-103 82.68-103 68.5 0 91.5 28.3 91.5 106.7z" fill="blue" stroke-linecap="round" stroke-linejoin="round" stroke-width="5"/>
  39   <path d="m100.7 474.4c-14.07-18.3-37.61-27.7-74.74-27.2 24.58-20.4 52.82-34 95.74-20.9z" fill="blue" fill-rule="evenodd"/>
  40   <path d="m246.1 477c8.9-19.9 28.3-32.9 62.3-40.3-26.7-13.6-54.9-20.4-91.5.6z" fill="blue" fill-rule="evenodd"/>
  41   <path d="m165.3 609.5c20.4-28.7 44.9-86.2 72.5-139.5 10.8-25.2 34.1-43.7 34.1-43.7l-34.7-6-52.1 107.2-27 82.6z" fill="#000" fill-opacity="0.4" fill-rule="evenodd" stroke-width=".9999"/>
  42   <path d="m159.6 614.5c-8.4-.8-37-107.5-69.76-154.1l-28.16-34.7 7.19-4.2 62.33 76z" fill="#000" fill-opacity="0.4" fill-rule="evenodd" stroke-width=".9999"/>
  43   <path d="m43.74 403.8c84.76-37.7 175.16-16.8 249.46 2.1-79 42.9-87.9 146.4-133.4 209.7-38.7-74.3-17.7-116.1-116.06-211.8z" fill="magenta" fill-rule="evenodd" stroke-width=".92"/>
  44   <path d="m171.4 435.7c-91.57-13.1-67-109.8-62.8-192.5 5.7-110.9 39.2-172.57 113-160.02 64.8 10.46 32.4 77.92 15.7 187.72-16.8 109.9 9.9 175.2-65.9 164.8z" fill="#e6c8aa" stroke-linecap="round" stroke-linejoin="round" stroke-width="5"/>
  45   <circle cx="117.5" cy="183.1" r="4.239" stroke-linecap="round" stroke-linejoin="round" stroke-width="5"/>
  46   <path d="m108.1 168.4c9.9-2.6 18.3 3.2 25.6 14.2" fill="none" stroke="#000" stroke-width="6.1714"/>
  47   <circle cx="-169.8" cy="188.3" r="4.239" stroke-linecap="round" stroke-linejoin="round" stroke-width="5" transform="scale(-1 1)"/>
  48   <path d="m179.7 173.7-26.1 14.1" fill="none" stroke="#000" stroke-width="6.1714"/>
  49   <g transform="matrix(5.014 0 0 5.014 -2492 -2615)">
  50     <path d="m532.1 567.7c0 2.3-2.6 4.3-8.3 4.3-5.8 0-5-2-5-4.3 0-2.4-.8-4.2 5-4.2 5.7 0 8.3 1.8 8.3 4.2z" fill="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="5"/>
  51     <path d="m472.7 206.4c-.1 0-.2 0-.3 0v3.3h-2.2l-.1-3.1c-.3 0-.7.1-.9.2v2.9h-1.2v.6.3h1.2v3.4c.3.1.6.2 1 .3v-3.6h2.2v3.8h.3.7v-3.8h2.8v3.5c.4-.1.7-.2 1-.3v-3.2l3.5.1c0-.2 0-.3 0-.5s0-.3 0-.5h-3.5l-.1-2.9c-.3-.1-.6-.2-.9-.3v3.2l-2.9-.1v-3.3c-.2 0-.3 0-.6 0z" fill-rule="evenodd" transform="matrix(1.043 0 0 1.043 30.66 348.3)"/>
  52   </g>
  53   <path d="m139.6 132.2s11.4 20.9 49.1 25.7c27.5 1.8 50.9-16.7 50.9-16.7l-9 15.5s-24.5 34.7-26.3 57.5c0 0-16.8 92.8-12.6 119.8 0 0 7.1 10.2 19.7 9.6 21.6-3 18.6-13.8 18.6-13.8s.6-44.3 0-49.1 8.4-86.8 8.4-86.8l25.7-44.4 7.2-32.3-91.6-20.37-57.5-3.59 6 35.96z" fill="#ddb38a" fill-rule="evenodd" stroke-width=".9999"/>
  54   <path d="m129.5 137.6c-15.7-37.2-40.26-72.2-24.6-116.65 34.6 6.8 28.8 20.39 46.6 28.24 41.8 16.73 71.6 27.19 142.8 66.41-1.1 20.4-4.7 38.2-27.8 42.9-32.9 75.3-24 119.2-37.6 171.5-7.9 6.3-17.3 8.9-33.5-4.1 3.7-46.1 2.1-131.8 56.5-189.4-7.3 2.1-4.2-11-18.3 0-31.4 25.1-74.8 11.5-93.1-16.2-2.6-3.6-6.3 18.3-11 17.3z" fill="#736357" fill-rule="evenodd"/>
  55   <g stroke-linecap="round" stroke-linejoin="round">
  56     <path d="m91.34 478.6s-136.51 11.5-53.87 119.2" fill="none" stroke="blue" stroke-width="11.9244"/>
  57     <path d="m64.14 587.4c10.46 13 3.14 20.9-9.41 31.3-13.08 10-19.88 15.7-30.34 2.7-9.94-12.6-6.27-20.4 6.8-30.9 12.55-9.9 23.01-15.7 32.95-3.1z" fill="#e6c8aa" stroke-width="2"/>
  58     <path d="m123.2 610.4s-34.48 11.5-24.02 91.5l-33.47 4.2" fill="none" stroke="blue" stroke-width="11.9244"/>
  59     <path d="m244.1 486.4s136.5 11.5 53.8 119.8" fill="none" stroke="blue" stroke-width="11.9244"/>
  60     <path d="m270.7 595.7c-9.9 12.6-2.6 20.4 10 30.9 13 10.4 19.8 15.7 29.8 3.1 10.4-13.1 6.2-20.9-6.3-30.8-13.1-10.5-23-16.3-33.5-3.2z" fill="#e6c8aa" stroke-width="2"/>
  61     <path d="m199.6 604.1s34.5 11.5 24.1 91.5l30.8 10.5" fill="none" stroke="blue" stroke-width="11.9244"/>
  62   </g>
  63   <path d="m8.178 700.3c-5.753-7.8 35.042-700.274 35.042-700.274l253.68 99.894 37.1 605.68z" fill="none"/>
  64   <path d="m115.4 404.8c46.5 67.5 22.5 115.1 49.2 165.8 8.3-63.8 28.7-108.2 60.6-161.6z" fill="#e6c8aa" fill-rule="evenodd"/>
  65 </svg>
  66 SVG
  67 # }}}
  68 
  69 sed -i "
  70     s/#ff0000\|red/$red1/Ig
  71     s/#00ff00\|green/$green1/Ig
  72     s/#ffff00\|yellow/$yellow1/Ig
  73     s/#0000ff\|blue/$blue1/Ig
  74     s/#ff00ff\|magenta/$magenta1/Ig
  75     s/#00ffff\|cyan/$cyan1/Ig
  76 
  77     s/#f00\|red/$red1/Ig
  78     s/#0f0\|green/$green1/Ig
  79     s/#ff0\|yellow/$yellow1/Ig
  80     s/#00f\|blue/$blue1/Ig
  81     s/#f0f\|magenta/$magenta1/Ig
  82     s/#0ff\|cyan/$cyan1/Ig
  83 " $f.svg
  84 
  85 rsvg-convert -aw $s      $f.svg > $f.png ||
  86 convert -background none $f.svg   $f.png
  87 
  88 convert -size $r xc:$background -depth 8 \
  89 \( -background none $f.png -resize x$s -sharpen 1 \) \
  90 -gravity southeast -geometry +60+30 -composite $f.png
  91 
  92 theme -b $f.png