This repository has been archived by the owner on Jul 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
sharenix-window
executable file
·55 lines (45 loc) · 1.57 KB
/
sharenix-window
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh
# uploads a screenshot of the focused window using sharenix
#
# requires:
# - https://github.com/Francesco149/sharenix
# - any of:
# maim + xdotool
# http://www.linuxbrit.co.uk/scrot
# https://github.com/GNOME/gnome-screenshot
# http://goodies.xfce.org/projects/
# applications/xfce4-screenshooter
# not sleeping appears to cause glitchyness on some DEs
# feel free to comment this out
sleep 0.2s
if command -v xfce4-screenshooter > /dev/null 2>&1; then
xfce4-screenshooter -w -o "sharenix -n $*"
exit $?
fi
# some implementations of mktemp (such as busybox's) don't allow
# extensions at the end of the template so we rename the file
sharenixtmp=$(mktemp /tmp/nicememe.XXXXXXXXXXXXXXXXXXX)
mv "$sharenixtmp" "$sharenixtmp.png"
sharenixtmp="$sharenixtmp.png"
if command -v gnome-screenshot > /dev/null 2>&1; then
gnome-screenshot -w -f $sharenixtmp || exit $?
elif command -v maim > /dev/null 2>&1; then
maim -i $(xdotool getactivewindow) $sharenixtmp || exit $?
elif command -v scrot > /dev/null 2>&1; then
scrot -o -u $sharenixtmp || exit $?
elif command -v shot > /dev/null 2>&1; then
shot --output=$sharenixtmp --active-window || exit $?
else
echo "Couldn't find scrot, maim, shot, gnome-screenshot or " \
"xfce4-screenshooter."
echo "Please install either of them and try again"
exit 1
fi
# check file size (0b means that gnome-screenshot was cancelled)
sharenixtmpsize=$(wc -c <"$sharenixtmp")
if [ $sharenixtmpsize != 0 ]; then
sharenix -n "$@" $sharenixtmp
exit $?
fi
echo "Screenshot canceled"
exit 1