-
Notifications
You must be signed in to change notification settings - Fork 1
/
outdoor.sh
executable file
·86 lines (70 loc) · 1.53 KB
/
outdoor.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/sh
usage() {
cat >&2 << EOF
USAGE
$(basename $0) [OPTIONS...] </path/to/img>
OPTIONS
-b, --blur=NUM
sets image blur.
-t, --tile
tiles image (fills by default).
-s, --solid=COLOR
sets a solid color.
-i, --tint=COLOR
colorize the background.
EOF
exit $1
}
REND=-fill
BLUR=0
while test $# -gt 0; do
case "$1" in
-b|--blur)
BLUR="$2"
shift 2
;;
-t|--tile)
REND=-tile
shift 1
;;
-s|--solid)
SOLID="$2"
shift 2
break
;;
-i|--tint)
TINT="$2"
shift 2
break
;;
-h|--help)
usage 0
;;
*)
IMG="$1"
shift 1
;;
esac
done
wrong_arg() {
printf '%s\n' "$(basename $0): wrong argument for file: $1" >&2
usage 1
}
test -n "$SOLID" && {
hsetroot -solid "$SOLID"
cat << EOF >$HOME/.env/rootimg
#!/bin/sh
hsetroot -solid '$SOLID'
EOF
} || {
test -n "$IMG" || wrong_arg "no file was given"
test -f "$IMG" || wrong_arg "$IMG doesn't exist"
hsetroot $REND $IMG -blur $BLUR $([ -n "$TINT" ] && \
printf '%s' "-tint $TINT" || printf '%s' "")
cat << EOF >$HOME/.env/rootimg
#!/bin/sh
hsetroot $REND $IMG -blur $BLUR $(test -n "$TINT" && printf '%s' "-tint '$TINT'" \
|| printf '%s' "")
EOF
}
chmod a+x $HOME/.env/rootimg