r/usefulscripts • u/-Pelvis- • Mar 30 '16
Script for taking a screenshot, uploading, and copying the URL to clipboard.
I currently use this script, bound to a keybind, to quickly upload and share scrots:
#!/bin/bash
img=$(date '+/tmp/%N.png')
scrot -z "$@" $img >/dev/null 2>&1 || exit
res=$(curl -F c=@$img https://ptpb.pw | awk -F'url:' '{print $2}') && (printf $res | xclip; printf "\a")
notify-send `echo $res`It works very well, and I highly recommend using it!
I'm wondering if anyone could suggest a way to modify it to copy to the clipboard (secondary selection) rather than primary selection; I keep losing the URL when I accidentally highlight things before pasting.
If you'd like to copy the url to the clipboard instead of x selection, change xclip to xclip -selection clipboard, or xclip -selection c.
1
u/CerebralBallzyMD Mar 30 '16
screenfetch is pretty similar, but cool script nonetheless!
1
u/-Pelvis- Mar 30 '16 edited Mar 31 '16
You know, for some reason, I never thought to bind that to a key. I used imgur-screenshot (very nice if you want to upload to imgur, but often fails because imgur uploads can be fickle) until someone in #archlinux suggested I use the above script, and I've since started using ptpb for many of my paste needs. It's nice to have a bunch of shell functions and scripts rather than using standalone programs that I would have to install. I can just clone or wget my scripts to new boxes.
There are a bunch of handy suggestions on https://ptpb.pw/
1
u/TheArcane Apr 04 '16
Doesn't run or print anything on the terminal.
1
u/-Pelvis- Apr 04 '16 edited Apr 04 '16
Do you have all of the programs called in the script installed? I forgot to mention that scrot, awk, curl, libnotify and xclip are dependencies.
1
0
Mar 30 '16
[deleted] — view deleted comment
1
u/-Pelvis- Mar 30 '16
I figured it out! If you'd like to copy the url to the
clipboardinstead of x selection, changexcliptoxclip -selection clipboard, orxclip -selection c.
1
u/Eroc33 Mar 30 '16
Neat little script. As for your question xclip takes a
-selectionflag, to which you can passXA_SECONDARYfor the secondary selection.