Blame


1 432335a8 2022-02-21 op # sshot
2 432335a8 2022-02-21 op
3 432335a8 2022-02-21 op sshot is a simple script to make a screenshot!
4 432335a8 2022-02-21 op
5 432335a8 2022-02-21 op #!/bin/sh
6 432335a8 2022-02-21 op
7 432335a8 2022-02-21 op select=
8 432335a8 2022-02-21 op while getopts s name; do
9 432335a8 2022-02-21 op case $name in
10 432335a8 2022-02-21 op s) select=1 ;;
11 432335a8 2022-02-21 op ?) echo "Usage: $0 [-s]" >&2; exit 1 ;;
12 432335a8 2022-02-21 op esac
13 432335a8 2022-02-21 op done
14 432335a8 2022-02-21 op
15 432335a8 2022-02-21 op The usage is simple, it just accepts a -s flag to select a window
16 432335a8 2022-02-21 op instead of grabbing the whole screen.
17 432335a8 2022-02-21 op
18 432335a8 2022-02-21 op The image is saved in /tmp/YYYYMMDDHHMMSS.png
19 432335a8 2022-02-21 op
20 432335a8 2022-02-21 op file=/tmp/`date +%Y%m%d%H%M%S`.png
21 432335a8 2022-02-21 op
22 432335a8 2022-02-21 op if [ -n "$select" ]; then
23 432335a8 2022-02-21 op maim -su > "$file"
24 432335a8 2022-02-21 op else
25 432335a8 2022-02-21 op maim -u > "$file"
26 432335a8 2022-02-21 op fi
27 432335a8 2022-02-21 op
28 432335a8 2022-02-21 op During the "select" maim aborts if a key is pressed; this however leaves
29 432335a8 2022-02-21 op a zero-byte file around, something I don't really like, so remove it in
30 432335a8 2022-02-21 op case
31 432335a8 2022-02-21 op
32 432335a8 2022-02-21 op if [ $? -ne 0 ]; then
33 432335a8 2022-02-21 op rm "$file"
34 432335a8 2022-02-21 op notify-send "sshot: aborted"
35 432335a8 2022-02-21 op exit 1
36 432335a8 2022-02-21 op fi
37 432335a8 2022-02-21 op
38 432335a8 2022-02-21 op Then send a notification to give a feedback of the success
39 432335a8 2022-02-21 op
40 432335a8 2022-02-21 op notify-send "sshot: done" "$file"