2021-03-30 20:59:59 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
2022-11-25 11:36:10 +00:00
|
|
|
rclone_remote="s3-serguzim-me:public/screenshots"
|
|
|
|
screenshot_host="https://s3.serguzim.me/public/screenshots"
|
|
|
|
path="/tmp/screenshot.png"
|
|
|
|
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
|
|
|
{
|
2022-11-25 11:36:10 +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()
|
|
|
|
{
|
2022-11-25 11:36:10 +00:00
|
|
|
# to have link available in clipboard manager
|
|
|
|
printf '%s' "$screenshot_host/$file" | xclip -selection clipboard
|
|
|
|
printf '%s' "$screenshot_host/$file" | xclip -selection primary
|
|
|
|
rclone copyto "$1" "$rclone_remote/$file"
|
2021-04-01 17:00:33 +00:00
|
|
|
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()
|
|
|
|
{
|
2022-11-25 11:36:10 +00:00
|
|
|
if [ "$(flameshot gui -r | tee $path | wc -c)" -gt 0 ]
|
2021-04-23 17:38:05 +00:00
|
|
|
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
|
2022-11-25 11:36:10 +00:00
|
|
|
convert "$1" "$path"
|
|
|
|
upload_image "$path"
|
2022-12-20 00:09:47 +00:00
|
|
|
clip_image "$path"
|
2021-07-09 22:50:17 +00:00
|
|
|
else
|
2022-11-25 11:36:10 +00:00
|
|
|
if [ "$(flameshot gui -r | tee $path | wc -c)" -gt 0 ]
|
2021-07-09 22:50:17 +00:00
|
|
|
then
|
2022-11-25 11:36:10 +00:00
|
|
|
upload_image "$path"
|
2022-12-20 00:09:47 +00:00
|
|
|
clip_image "$path"
|
2021-07-09 22:50:17 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
no_upload) main_no_upload ;;
|
2022-11-25 11:36:10 +00:00
|
|
|
*) main "$1" ;;
|
2021-07-09 22:50:17 +00:00
|
|
|
esac
|