Improve screenshot tool (replace s3cmd with rclone) and fix other stuff
This commit is contained in:
parent
f0af2d26b0
commit
d0bbb66934
1 changed files with 17 additions and 15 deletions
|
@ -1,25 +1,27 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
s3_bucket=public.serguzim.me/screenshots
|
||||
s3_host=https://sos-de-fra-1.exo.io
|
||||
path=/tmp/screenshot.png
|
||||
file=$(date "+%F_%H-%M-%S").png
|
||||
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"
|
||||
|
||||
clip_image()
|
||||
{
|
||||
xclip -t image/png $1 -selection clipboard
|
||||
xclip -t image/png "$1" -selection clipboard
|
||||
}
|
||||
|
||||
upload_image()
|
||||
{
|
||||
echo -n "$s3_host/$s3_bucket/$file" | xclip -selection primary
|
||||
s3cmd put -P $1 s3://$s3_bucket/$file
|
||||
# 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"
|
||||
notify-send -a "Screenshot" "Uploaded screenshot to s3"
|
||||
}
|
||||
|
||||
main_no_upload()
|
||||
{
|
||||
if flameshot gui -r > $path
|
||||
if [ "$(flameshot gui -r | tee $path | wc -c)" -gt 0 ]
|
||||
then
|
||||
clip_image $path
|
||||
fi
|
||||
|
@ -29,19 +31,19 @@ main()
|
|||
{
|
||||
if [ -n "$1" ] && [ -e "$1" ]
|
||||
then
|
||||
convert $1 $path
|
||||
clip_image $path
|
||||
upload_image $path
|
||||
convert "$1" "$path"
|
||||
clip_image "$path"
|
||||
upload_image "$path"
|
||||
else
|
||||
if flameshot gui -r > $path
|
||||
if [ "$(flameshot gui -r | tee $path | wc -c)" -gt 0 ]
|
||||
then
|
||||
clip_image $path
|
||||
upload_image $path
|
||||
clip_image "$path"
|
||||
upload_image "$path"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
case $1 in
|
||||
no_upload) main_no_upload ;;
|
||||
*) main $1 ;;
|
||||
*) main "$1" ;;
|
||||
esac
|
||||
|
|
Loading…
Reference in a new issue