aboutsummaryrefslogtreecommitdiffhomepage
path: root/X11/image
diff options
context:
space:
mode:
Diffstat (limited to 'X11/image')
-rwxr-xr-xX11/image/takeshot79
1 files changed, 79 insertions, 0 deletions
diff --git a/X11/image/takeshot b/X11/image/takeshot
new file mode 100755
index 0000000..9f34f26
--- /dev/null
+++ b/X11/image/takeshot
@@ -0,0 +1,79 @@
1#!/usr/bin/env bash
2
3## Copyright (C) 2020-2022 Aditya Shakya <adi1090x@gmail.com>
4## Everyone is permitted to copy and distribute copies of this file under GNU-GPL3
5
6## Script to take screenshots with maim
7
8time=`date +%Y-%m-%d-%H-%M-%S`
9geometry=`xrandr | head -n1 | cut -d',' -f2 | tr -d '[:blank:],current'`
10dir="`xdg-user-dir PICTURES`"
11file="Screenshot_${time}_${geometry}.png"
12
13# notify and view screenshot
14notify_view () {
15 dunstify -u low --replace=699 -i /usr/share/archcraft/icons/dunst/picture.png "Copied to clipboard."
16 viewnior ${dir}/"$file"
17 if [[ -e "$dir/$file" ]]; then
18 dunstify -u low --replace=699 -i /usr/share/archcraft/icons/dunst/picture.png "Screenshot Saved."
19 else
20 dunstify -u low --replace=699 -i /usr/share/archcraft/icons/dunst/picture.png "Screenshot Deleted."
21 fi
22}
23
24# countdown
25countdown () {
26 for sec in `seq $1 -1 1`; do
27 dunstify -t 1000 --replace=699 -i /usr/share/archcraft/icons/dunst/timer.png "Taking shot in : $sec"
28 sleep 1
29 done
30}
31
32# take shots
33shotnow () {
34 cd ${dir} && maim -u -f png | tee "$file" | xclip -selection clipboard -t image/png
35 notify_view
36}
37
38shot5 () {
39 countdown '5'
40 sleep 1 && cd ${dir} && maim -u -f png | tee "$file" | xclip -selection clipboard -t image/png
41 notify_view
42}
43
44shot10 () {
45 countdown '10'
46 sleep 1 && cd ${dir} && maim -u -f png | tee "$file" | xclip -selection clipboard -t image/png
47 notify_view
48}
49
50shotwin () {
51 cd ${dir} && maim -u -f png -i `xdotool getactivewindow` | tee "$file" | xclip -selection clipboard -t image/png
52 notify_view
53}
54
55shotarea () {
56 set -o pipefail
57 cd ${dir} && maim -u -f png -s -b 2 -c 0.35,0.55,0.855 | tee "$file" | xclip -selection clipboard -t image/png && \
58 notify_view
59}
60
61if [[ ! -d "$dir" ]]; then
62 mkdir -p "$dir"
63fi
64
65if [[ "$1" == "--now" ]]; then
66 shotnow
67elif [[ "$1" == "--in5" ]]; then
68 shot5
69elif [[ "$1" == "--in10" ]]; then
70 shot10
71elif [[ "$1" == "--win" ]]; then
72 shotwin
73elif [[ "$1" == "--area" ]]; then
74 shotarea
75else
76 echo -e "Available Options : --now --in5 --in10 --win --area"
77fi
78
79exit 0