.dotfiles/.bin/screenshot

48 lines
850 B
Plaintext
Raw Normal View History

2021-03-30 20:59:59 +00:00
#!/usr/bin/env sh
s3_bucket=public.serguzim.me/screenshots
s3_host=https://sos-de-fra-1.exo.io
path=/tmp/screenshot.png
2021-07-09 22:50:17 +00:00
file=$(date "+%F_%H-%M-%S").png
2021-03-30 20:59:59 +00:00
2021-07-09 22:50:17 +00:00
clip_image()
2021-04-23 17:38:05 +00:00
{
xclip -t image/png $1 -selection clipboard
2021-07-09 22:50:17 +00:00
}
2021-03-30 20:59:59 +00:00
2021-07-09 22:50:17 +00:00
upload_image()
{
echo -n "$s3_host/$s3_bucket/$file" | xclip -selection primary
2021-07-09 22:50:17 +00:00
s3cmd put -P $1 s3://$s3_bucket/$file
notify-send -a "Screenshot" "Uploaded screenshot to s3"
2021-04-23 17:38:05 +00:00
}
2021-03-30 20:59:59 +00:00
2021-07-09 22:50:17 +00:00
main_no_upload()
{
2021-04-23 17:38:05 +00:00
if flameshot gui -r > $path
then
2021-07-09 22:50:17 +00:00
clip_image $path
2021-04-23 17:38:05 +00:00
fi
2021-07-09 22:50:17 +00:00
}
main()
{
if [ -n "$1" ] && [ -e "$1" ]
then
convert $1 $path
clip_image $path
upload_image $path
else
if flameshot gui -r > $path
then
clip_image $path
upload_image $path
fi
fi
}
case $1 in
no_upload) main_no_upload ;;
*) main $1 ;;
esac