[download]

local/bin/picker

   1 #!/bin/bash
   2 
   3 f=~/.cache/${0##*/}
   4 
   5 ocr(){    echo "$@"; }; export -f ocr
   6 qrcode(){ echo "$@"; }; export -f qrcode
   7 
   8 [[ $1 ]] || printf '%s\n' Color Qrcode Ocr | icon -x picker |
   9 menu -i picker | awk '{ print tolower($NF) }'| xargs -rI % $0 --%
  10 
  11 [[ $1 == -q || $1 == --qr* ]] && { # {{{
  12     s=$(maim -s | zbarimg --raw - - 2>&-)
  13 
  14     [[ $s ]] || exit
  15 
  16     echo -n "$s" | xsel -ib
  17     notify qrcode "$s"
  18     exit
  19 } # }}}
  20 [[ $1 == -o || $1 == --oc* ]] && { # {{{
  21     s=$(maim -s | tesseract -l rus+eng - - 2>&- | sed '/^\s*$/d')
  22 
  23     [[ $s ]] || exit
  24 
  25     echo -n "$s" | xsel -ib
  26     notify ocr "$s"
  27     exit
  28 } # }}}
  29 [[ $1 == -c || $1 == --co* ]] && { # {{{
  30     s=$(gpick -so | tr A-Z a-z)
  31 
  32     [[ $s ]] || exit
  33     (( 16$s >= 16#777776 )) && c=\#000 || c=\#fff
  34 
  35     printf '<svg width="22" height="22"><text font-family="Nerdfont"
  36     y="18" font-size="20" fill="%s">%s</text></svg>' $c $(icon picker) > $f
  37 
  38     echo -n "$s" | xsel -ib
  39     notify-send -a picker -i $f -h string:bgcolor:$s -h string:fgcolor:$c -- Picker $s
  40 } # }}}