others/screenshot.sh

98 lines
2.0 KiB
Bash
Executable File

#!/bin/sh
## images and bragging with your pretty desktop ##
# screenshot.sh by @root_informatica.
# xmenu.
MENU=xmenu.sh
# wmutils binary. (It can also be done with xdotool)
TARGET=$(pfw)
# date.
DATE=`date +%m-%d-%Y_%H:%M:%S`
# legend to insert in the screnshots.
SIGNATURE=$(cat $HOME/.signature)
# time interval, just to improve performance.
DELAY="sleep 1"
# options
OPT=$(echo -e "desktop\nfancy\nwindow\nmultiwindow\nselection\nmultiselect\nedit\nshare" \
| $MENU)
# capture the desktop
desktop() {
import -w root ~/Imágenes/screenshot/screenshot_$DATE.png
}
# capture the desktop with signature
fancy() {
import -w root /tmp/screenshot.png
convert /tmp/screenshot.png \
-gravity South \
-font DejaVu-Sans-Bold-Oblique \
-background transparent \
-fill 'rgba(255,255,255,0.35)' \
-pointsize 50 \
-annotate +420+4 "$SIGNATURE" ~/Imágenes/screenshot/screenshot_$DATE.png
}
# capture focused window
window() {
import -w $TARGET ~/Imágenes/screenshot/screenshot_$DATE.png
}
# select region
selection() {
import ~/Imágenes/screenshot/screenshot_$DATE.png
}
# select multiple regions
multiselection() {
rm /tmp/*.png
import -snaps $(echo -e "2\n3\n4\n5\n6" | $MENU) /tmp/screeshot.png
convert -background black \
-append /tmp/*.png ~/Imágenes/screenshot/selection_compose_$DATE.png
}
# edit after capturing the desktop
edit() {
import -w root /tmp/screenshot_edit.png
display -backdrop -background '#000000' -foreground '#55af66' /tmp/screenshot_edit.png
}
# share desktop [ https://0x0.st ]
share() {
import /tmp/screenshare.png
curl -F "file=@/tmp/screenshare.png" -F "secret=" https://0x0.st | xclip
xclip -o | xclip -sel c
}
case $OPT in
desktop)
$DELAY
desktop
;;
fancy)
$DELAY
fancy
;;
window)
window
;;
selection)
selection
;;
multiselect)
multiselection
;;
edit)
$DELAY
edit
;;
share)
share
;;
quit) # exit
exit 0
;;
esac