first push of my config files
[my-dotfiles.git] / bin / i3-scrot
CommitLineData
fdd76fc5 1#!/bin/sh
2# /usr/bin/i3-scrot
3#
4# simple screenshot-script using scrot for manjaro-i3 by oberon@manjaro.org
5
6_conf=$HOME/.config/i3-scrot.conf
7
8if ! [ -f $_conf ]; then
9 echo "scrot_dir=$(xdg-user-dir PICTURES)" > $_conf
10fi
11
12source $_conf
13
14if ! [ -d $scrot_dir ]; then
15 mkdir -p $scrot_dir
16fi
17
18if ! [[ -z "$2" ]]; then
19 cmd="scrot -d $2"
20else
21 cmd='scrot'
22fi
23
24case "$1" in
25 --desk|-d|$NULL)
26 cd $scrot_dir
27 $cmd &&
28 sleep 1 &&
29 notify-send "screenshot has been saved in $scrot_dir"
30 ;;
31 --window|-w)
32 cd $scrot_dir
33 $cmd -u &&
34 sleep 1 &&
35 notify-send "screenshot has been saved in $scrot_dir"
36 ;;
37 --select|-s)
38 cd $scrot_dir
39 notify-send 'select an area for the screenshot' &
40 $cmd -s &&
41 sleep 1 && notify-send "screenshot has been saved in $scrot_dir"
42 ;;
43 --help|-h)
44 echo "
45available options:
46-d | --desk full screen
47-w | --window active window
48-s | --select selection
49-h | --help display this information
50
51The -d or -w options can be used with a delay
52by adding the number of seconds, like for example:
53'i3-scrot -w 5'
54
55Default option is 'full screen'.
56
57The file destination can be set in ${_conf}.
58Default is $scrot_dir
59"
60 ;;
61 *)
62 echo "
63== ! i3-scrot: missing or wrong argument ! ==
64
65available options:
66-d | --desk full screen
67-w | --window active window
68-s | --select selection
69-h | --help display this information
70
71Default option is 'full screen'.
72
73The file destination can be set in ${_conf}.
74Default is $scrot_dir
75"
76
77 exit 2
78esac
79
80exit 0