-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscreenshot.sh
executable file
·60 lines (52 loc) · 1.58 KB
/
screenshot.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# `screenshot.sh take-full` takes screenshot of full screen
# `screenshot.sh term-to-paper` converts dark terminal screenshots to whit backgrounds, saves ink while printing :)
# `screenshot.sh record` select an area on screen and record, useful for showing how-to-do gifs
# `screenshot.sh upload FILENAME` uploads to imgur, todo this
COMMAND=$1
OPTS=$2
FILENAME="Screenshot_from_$(date +%Y-%m-%d_%H-%M-%S).jpg"
FILEPATH=~/Pictures/screenshots/$FILENAME
function clip {
read -r G < <(slop -f "%g")
# pkill compton # kill compton to remove terminal transperancy
import -window root -crop $G $FILEPATH
# compton -b # restart compton, todo make it import args from .xinitrc
notify-send "Screenshot captured $FILENAME"
}
function optimize_paper {
clip
convert $FILEPATH \
-negate \
-colorspace gray \
-intensity Brightness \
-normalize \
-black-threshold 50% \
$(echo $FILEPATH | sed 's/.jpg/_paper.jpg/')
}
function screen_record {
RECORDFNAME=$(echo $FILENAME | sed -e 's/Screenshot/Screenrecord/' -e 's/.jpg/.mp4/')
read -r X Y W H G < <(slop -f "%x %y %w %h %g")
echo "Recording video $W $H $X $Y"
ffmpeg \
-framerate 25 \
-f x11grab \
-video_size "$W"x"$H" \
-i :0.0+$X,$Y \
-f pulse -ac 2 -i alsa_output.pci-0000_00_1f.3.analog-stereo.equalizer.monitor \
~/Videos/screenrecords/$RECORDFNAME
notify-send "Screen Record saved $RECORDFNAME"
}
case $COMMAND in
"take-full")
import -window root ~/Pictures/screenshots/$FILENAME;
echo "Screenshot taken!" ;;
"upload")
;;
"term-to-paper")
optimize_paper $OPTS ;;
"record")
screen_record ;;
*)
;;
esac