shot/shot

59 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
args=`getopt wu $*`
eval set -- "${args}"
directory="${HOME}/files/shot"
endpoint="http://0x0.tilde.team"
flag_window=0
flag_upload=0
while true; do
case "$1" in
-w)
flag_window=1
shift
;;
-u)
flag_upload=1
shift
;;
--)
shift
break
;;
*)
echo 'internal error'
exit 3
;;
esac
done
if [ -z $1 ]; then
filename="$(date +'screen_%T_%F')"
else
filename="${$1}"
fi
if [ ${flag_window} -gt 0 ]; then
import -window root "${directory}/${filename}.png"
else
import "${directory}/${filename}.png"
fi
command_loc="$(command -v "alert" 2> /dev/null)"
if [ ${flag_upload} -gt 0 ]; then
echo "${directory}/${filename}.png" | pb -f | tr -d '\n' | xclip -selection clipboard
if [ ! -z "$command_loc" ]; then
alert "Saved screenshot to ${directory}/${filename}.png and uploaded to $(xp)"
else
export EDITOR="nano"
fi
else
if [ ! -z "$command_loc" ]; then
alert "Saved screenshot to ${directory}/${filename}.png"
else
export EDITOR="nano"
fi
fi