47 lines
		
	
	
	
		
			850 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
	
		
			850 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
#!/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
 | 
						|
 | 
						|
clip_image()
 | 
						|
{
 | 
						|
    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
 | 
						|
    notify-send -a "Screenshot" "Uploaded screenshot to s3"
 | 
						|
}
 | 
						|
 | 
						|
main_no_upload()
 | 
						|
{
 | 
						|
    if flameshot gui -r > $path
 | 
						|
    then
 | 
						|
        clip_image $path
 | 
						|
    fi
 | 
						|
}
 | 
						|
 | 
						|
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
 |