Here is a script I use for taking screenshots. It uses dmenu
to select the type of screenshot. It relies on notify-send
to send annoying notifications, and xclip
for the options that upload the screenshot so that I can take the shot, then immediately paste the link somewhere.
The Script dmenu_scrot.sh
#!/usr/bin/env bash
set -o pipefail
IMG_PATH=$HOME/Pictures/dumps/
UL="pb 0x0"
TIME=3000 #Seconds notification should remain visible
FILENAME=$(date +%Y-%m-%d_@_%H-%M-%S-scrot.png)
prog="1.Fullscreen
2.Delay_Fullscreen
3.Draw_Section
4.Window
5.Fullscreen_UL
6.Delay_Fullscreen_UL
7.Draw_Section_UL"
cmd=$(dmenu -l 20 -fn CodeNewRomanNerdFont:style=Normal:pixelsize=13:antialias=true -nb "#1f1b18" -nf "#c5b3a6" -sb "#93a1a1" -sf "#000000" -p 'Choose Screenshot Type' <<< "$prog")
cd $IMG_PATH
case ${cmd%% *} in
1.Fullscreen) scrot -d 1 $FILENAME && notify-send -t $TIME -a "Screenshot" "$(echo $IMG_PATH$FILENAME)" ;;
2.Delay_Fullscreen) scrot -d 4 $FILENAME && notify-send -t $TIME -a "Screenshot" "$(echo $IMG_PATH$FILENAME)" ;;
3.Draw_Section) scrot -s $FILENAME && notify-send -t $TIME -a "Screenshot: Section" "$(echo $IMG_PATH$FILENAME)" ;;
4.Window) scrot -ub -d 1 $FILENAME && notify-send -t $TIME -a "Screenshot: Window" "$(echo $IMG_PATH$FILENAME)" ;;
5.Fullscreen_UL) scrot -d 1 $FILENAME && $UL $FILENAME | xclip -sel prim && notify-send -t $TIME -a "Screenshot Uploaded" "$(xclip -o;echo)" ;;
6.Delay_Fullscreen_UL) scrot -d 4 $FILENAME && $UL $FILENAME | xclip -sel prim && notify-send -t $TIME -a "Sreenshot Uploaded" "$(xclip -o;echo)" ;;
7.Draw_Section_UL) scrot -s $FILENAME && $UL $FILENAME | xclip -sel prim && notify-send -t $TIME -a "Screenshot Uploaded" "$(xclip -o;echo)";;
*) exec "'${cmd}'" ;;
esac
$UL
(UpLoad) calls a little pastebin script:
#!/bin/sh
usage () {
cat <<EOF
Services: 0x0|null, envs|pb, catbox|cat
Usage: pb <service> <file>
EOF
exit 0
}
ARG="${2:-/dev/stdin}"
UA=${UA:="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36"}
case $1 in
0x0|null)
curl -A "$UA" -sF 'file=@-' https://0x0.st < $ARG
;;
envs|pb)
curl -A "$UA" -sF 'file=@-' https://envs.sh < $ARG
;;
catbox|cat)
curl -A "$UA" -sF 'reqtype=fileupload' -F 'fileToUpload=@-' https://catbox.moe/user/api.php < $ARG
;;
*)
usage
;;
esac
This works pretty well, however, While xclip
picks up the url for each screenshot and sends it to notify-send
for the notification, I am unable to paste the output...
It's asif there are two clipboards. Because I can Copy and Paste things with the usual shift+ctrl+C
and shift+ctrl+V
I've discovered that when I use xclip -sel prim
the url is sent to the notification correctly with xclip -o; echo
but I cannot paste it with shift+ctrl+V
. However, when I use xclip -sel clip
the output from xclip -o; echo
is incorrect but I can sucessfully shift+ctrl+V
and get the correct paste....
Someone please tell me what on earth is going on.
Thank you.