Add rushlink --screenshot. #41
@ -31,6 +31,9 @@ del() {
|
|||||||
URL="$LINK$1"
|
URL="$LINK$1"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
# Remove file extension, if any.
|
||||||
|
NAME="${URL##*/}"
|
||||||
|
URL="${URL%/*}/${NAME%%.*}"
|
||||||
if DELURL=$(grep -s -m1 "$URL?deleteToken=" "$DELFILE"); then
|
if DELURL=$(grep -s -m1 "$URL?deleteToken=" "$DELFILE"); then
|
||||||
echo "Deleting $URL..." >&2
|
echo "Deleting $URL..." >&2
|
||||||
curl -sS -X DELETE "$DELURL" | grep deleted
|
curl -sS -X DELETE "$DELURL" | grep deleted
|
||||||
@ -40,6 +43,29 @@ del() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
screenshot() {
|
||||||
|
if command -v maim >/dev/null 2>&1; then
|
||||||
|
CMD="maim -ks"
|
||||||
|
elif command -v import >/dev/null 2>&1; then
|
||||||
|
CMD="import png:-"
|
||||||
|
else
|
||||||
|
echo "Neither maim nor import were found. One of these is needed to make screenshots." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
FILE=$(mktemp)
|
||||||
|
if $CMD > "$FILE"; then
|
||||||
|
LINK=$(link "$FILE")
|
||||||
|
rm -f "$FILE"
|
||||||
|
echo "$LINK.png"
|
||||||
|
if command -v xdg-open >/dev/null 2>&1; then
|
||||||
|
xdg-open "$LINK.png"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
rm -f "$FILE"
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ]; then
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--help|-h)
|
--help|-h)
|
||||||
@ -55,6 +81,8 @@ if [ $# -gt 0 ]; then
|
|||||||
echo " $CMD"
|
echo " $CMD"
|
||||||
echo " echo hi | $CMD"
|
echo " echo hi | $CMD"
|
||||||
echo " Upload file from standard input."
|
echo " Upload file from standard input."
|
||||||
|
echo " $CMD (--screenshot|-s)"
|
||||||
|
echo " Select a window or an area of your screen, and upload it as png."
|
||||||
echo " $CMD (--delete|-d) ${LINK}xd42"
|
echo " $CMD (--delete|-d) ${LINK}xd42"
|
||||||
echo " $CMD (--delete|-d) xd42"
|
echo " $CMD (--delete|-d) xd42"
|
||||||
echo " Delete file or shortened link."
|
echo " Delete file or shortened link."
|
||||||
@ -69,6 +97,15 @@ if [ $# -gt 0 ]; then
|
|||||||
done
|
done
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
--screenshot|-s)
|
||||||
|
shift
|
||||||
|
if [ $# -gt 0 ]; then
|
||||||
|
echo "No arguments expected to --screenshot" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
screenshot
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
for url in "$@"; do
|
for url in "$@"; do
|
||||||
link "$url"
|
link "$url"
|
||||||
|
Loading…
Reference in New Issue
Block a user