summaryrefslogtreecommitdiff
path: root/bin/guiscripts/imgclip
blob: 466f2c62c548c28a8282328e28e3827fe3f5de8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

tmppic="/tmp/imgclip.png"
if [ "$WAYLAND_DISPLAY" ]
then
	clipo='wl-paste -n'
	clipp='wl-copy -n'
else
	clipo='xclip -o -selection clipboard -r'
	clipp='xclip -selection clipboard -r'
fi

$clipo > $tmppic 2>/dev/null
ftype="$(file /tmp/imgclip.png -bi | cut -f 1 -d ';')"
if [ "$ftype" != image/png ]
then
	notify-send "$(basename $0)" "Not an image."
	exit 1
fi

tesseract "$tmppic" stdout | $clipp

notify-send "$(basename $0)" "<i>$($clipo)</i>"